C
Cambalinho
Guest
the image file is a binary file and it's a structure file.
i can read the image size from BMP, JPG and GIF.
now i'm trying read from an Icon file.
heres the structure:
All values in ICO/CUR files are represented in little-endian byte order.
Header
ICONDIR structure
Offset# Size (in bytes) Purpose
0 2 Reserved. Must always be 0.
2 2 Specifies image type: 1 for icon (.ICO) image, 2 for cursor (.CUR) image. Other values are invalid.
4 2 Specifies number of images in the file.
Structure of image directory
Image #1 Entry for the first image
Image #2 Entry for the second image
...
Image #n Entry for the last image
Image entry
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.
2 1 Specifies number of colors in the color palette. Should be 0 if the image does not use a color palette.
3 1 Reserved. Should be 0.[Notes 2]
4 2 In ICO format: Specifies color planes. Should be 0 or 1.[Notes 3]
In CUR format: Specifies the horizontal coordinates of the hotspot in number of pixels from the left.
counting the bytes, the width is on 6 position..
so i did these code:
namespace little_endian
{
unsigned read_word( std::istream& ins )
{
unsigned a = ins.get();
unsigned b = ins.get();
return b << 8 | a;
}
}
FileImage.seekg( 6 );
height = little_endian::read_word( FileImage );
FileImage.seekg( 7 );
width = little_endian::read_word( FileImage );
but i get zero from both and i don't know why
i'm new reading image files and more without using the structure, but i only need the size and learn more about it.
yes i have these same question on other forums, for i learn what i can about it.
Continue reading...
i can read the image size from BMP, JPG and GIF.
now i'm trying read from an Icon file.
heres the structure:
All values in ICO/CUR files are represented in little-endian byte order.
Header
ICONDIR structure
Offset# Size (in bytes) Purpose
0 2 Reserved. Must always be 0.
2 2 Specifies image type: 1 for icon (.ICO) image, 2 for cursor (.CUR) image. Other values are invalid.
4 2 Specifies number of images in the file.
Structure of image directory
Image #1 Entry for the first image
Image #2 Entry for the second image
...
Image #n Entry for the last image
Image entry
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.
2 1 Specifies number of colors in the color palette. Should be 0 if the image does not use a color palette.
3 1 Reserved. Should be 0.[Notes 2]
4 2 In ICO format: Specifies color planes. Should be 0 or 1.[Notes 3]
In CUR format: Specifies the horizontal coordinates of the hotspot in number of pixels from the left.
counting the bytes, the width is on 6 position..
so i did these code:
namespace little_endian
{
unsigned read_word( std::istream& ins )
{
unsigned a = ins.get();
unsigned b = ins.get();
return b << 8 | a;
}
}
FileImage.seekg( 6 );
height = little_endian::read_word( FileImage );
FileImage.seekg( 7 );
width = little_endian::read_word( FileImage );
but i get zero from both and i don't know why
i'm new reading image files and more without using the structure, but i only need the size and learn more about it.
yes i have these same question on other forums, for i learn what i can about it.
Continue reading...