You don't seem to realize that seeking to position 6 gives you the last byte of the ICONDIR structure not the first byte of the ICONDIRENTRY structure.
Next what are the types of height and width?
What is the purpose of the shifts?
now i'm reading 1 byte and use the little endian method. but i conitnues with zero
So you still don't realize that there is no "endian method" involved when reading single bytes?
And it would be better if you showed the smallest possible complete program that illustrates the problem. I really need to see exactly how all of the variables are declared.
And quit just throwing code at the problem until you understand the problem.
you need to stop and learn.
256 is zero in an unsigned byte.
show me the 8 bit pattern that means '256' ?
in base 2, binary, bits, whatever you want to call it... 256 is 9 bits.
if it is 128x128, that will fit in bytes, and you are doing something wrong if you don't get 128 there. It may do you a world of good to open the file in a hex editor and LOOK at its structure. What are the values, in the hex editor, of bytes # 6 and 7 or whatever they were?
Take it very slowly. Open the file in a hex editor, see what the bytes are and where they are. Make sure that 6 and 7 are not numbers from a human text that counts from 1 instead of zero, validate what you are doing. Maybe you are off by 1 due to 5/6 instead of 6/7 due to start at zero?
"ICONDIRENTRY structure
Offset# Size (in bytes) Purpose
0 1 Specifies image width in pixels. Can be any number between 0 and 255. Value 0 means image width is 256 pixels.
1 1 Specifies image height in pixels. Can be any number between 0 and 255. Value 0 means image height is 256 pixels."
"What are the values, in the hex editor, of bytes # 6 and 7 or whatever they were?"
i only know open it with Notepad.. is there another program for we see what you mean?
yes, fine 0 can mean 256. but YOU have to DO that.
if ==0 then set it 256, you need that IN your code, the computer doesn't know this special translation. If you just read it, you gonna get 0.
yes, get a hex editor (google this, find a free one, and use it). Notepad shows text only. You need to see the file in binary format. You may want to use it for a moment on a small text file to see how it works: try putting hello world with and end of line and a little more text in a file in notepad, and open that in the new tool. You will see the end of line byte(s) and the text and all and understand what you are seeing, then try the icon. end of lines are usually one or more of {10,13} or in hex, {A,D} (0X0D 0X0A) which you can see on the ascii table. You will see what I mean when you open it and look at it.
wow i tested with another icon file, and i get the right size of the 1st(16,X16), but when i select it on explorer, i get 256X256.... what these means?