| quant (78) | |||
I have binary image file gif format. How to simpless to take width & height my image? I try get it next, but unsuccesful.
Hex address 0x6 & 0x8 keeping value height & wight in according. | |||
|
|
|||
| helios (10126) | |
|
I don't understand the question. Are you getting absurd numbers? You might have an endianness problem. And what's lseek, anyway? | |
|
|
|
| Duoas (6732) | |||
|
If you haven't any clue what he is talking about then why post a reply? The logical screen width is at offset 6, and the screen height is at offset 8. You should be decoding it rather than relying on the machine size of any integer value:
I'm not sure why you are putting that carriage return in the output though... Hope this helps. | |||
|
|
|||
| helios (10126) | |
|
I don't understand him because he doesn't make himself clear, not because I don't know what the problem might be, smarty pants. I was trying to obtain more information to provide a better answer. "What's the simplest way of getting the height and width of an image"? Should I have said "getting it"? If he had said "the real values are x and y but I'm getting a and b" it'd be a different story, but there are so many ways something can be "unsuccessful" he might as well not say anything. | |
|
|
|
| Duoas (6732) | |
|
He made himself perfectly clear: he stated what he is trying to do, the data he is trying to do it on, provided the exact code he is trying to it with, and the exact problem he is having with it. That's a perfect question by any standard. If you are just going to acerbically attack everything that hits you the wrong way I'm going to start complaining to the site administrator. Oh, and double-talk self-rationalizations doesn't impress me much. | |
|
|
|
| helios (10126) | |
|
For the love of God, are you serious? So, to you, "unsuccessful" is an "exact problem"? "Acerbically attack"? I'll use your logic on yourself. If there was any chance that I would react, why bother saying anything at all? Why not just answer his question and leave it at that? No. You needlessly made a remark about me. I might have overreacted (I hardly consider that overreacting, but what the hell), but that's my temperament. Who the **** are you to criticize it? You know what? Go. Go complain to the admin, *******. I already know the Post Count Rule will apply, but what do I care? **** YOU. | |
|
Last edited on by admin
|
|
| admin (13) | |
| Please, stick to the topic. | |
|
|
|
| quant (78) | |
|
helios, be cool and to follow smb.'s example from Duoas. Duoas, thank for your answer. I take next error to use your sample.. error: subscripted value is neither array nor pointer on this row Width = buf[ 0 ] + (buf[ 1 ] << 8); A lot of about this... I want take dec value from specify hex address into binary file. | |
|
|
|
| Duoas (6732) | ||||
|
If you don't declare buf as either an array (as I did on line 1) or as a pointer then you cannot use the [] operator (subscript operator) on it. The only difference between decimal and hexadecimal is how it is written for us humans. 0xA and 10 are both the same number to the computer (and in reality). Use scanf() to read a hex representation into an integer variable:
Hope this helps. | ||||
|
|
||||
| quant (78) | |||||
|
thanks! But, how to send buf[ 0 ] + (buf[ 1 ] << 8) to getchar()?
valgrind
| |||||
|
Last edited on
|
|||||
| Duoas (6732) | |||||
|
It looks to me like you never initialized Data, buf, nor Width. You must open a file (and get its file descriptor) before you can read() it.
You have to set a pointer to point to something you are allowed to access before you can dereference it.
Was that it? | |||||
|
Last edited on
|
|||||
| quant (78) | |||
|
->You must open a file (and get its file descriptor) before you can read() it. Yea, it step I be made. Hm... When I want to print Data, take undeclared (first use in this function)? I've next listing.
| |||
|
Last edited on
|
|||
| Duoas (6732) | |||||
|
It looks to me like you are a bit more confused than I first thought. You absolutely must declare all variables before you use them, and they must be the correct type. Also, you cannot (well, should not) mix FILE* functions with File Descriptor functions. Choose one or the other. fopen() returns a FILE*. lseek() and read() don't use FILE*s, they use file descriptors. Use fopen() with fclose(), fseek(), and fread() (FILE*). Use open() with close(), lseek(), and read() (file descriptor). (A file descriptor is an int. If it helps, give it a type name with typedef.)
or
Oh, one last thing. Main must look like one of the following: int main() (C89) (C99)int main( int argc, char* argv[] ) (C89) (C99)int main( void ) (C99 only)Fix those things, try to compile, and post your full code and errors and we'll see what we can do. | |||||
|
|
|||||
| quant (78) | |||
Strange, but it did work incorrectly. Value equals 10 in dec with any input a file.
It possible take without pointers? p.s. Anybody have share ebook C++ for Real Programmers? | |||
|
Last edited on
|
|||
| Duoas (6732) | |||||
I think you need to spend some time looking through some tutorials on handling pointers and arrays. I don't really see why you need to use pointers at all, unless you are trying to return values through function arguments:
To use it:
People are always asking about books on the forum. I'm sure a search would return a lot of useful information. Hope this helps. | |||||
|
|
|||||