added checking and printing of magic number, printing of bounding rectangle, changed member names to be more descriptive
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3317 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -59,24 +59,37 @@ PrintBitsInfo(const char *filepath)
|
|||||||
// read in the rest of the header
|
// read in the rest of the header
|
||||||
ssize_t size = sizeof(TranslatorBitmap);
|
ssize_t size = sizeof(TranslatorBitmap);
|
||||||
if (file.Read(reinterpret_cast<uint8 *> (&header), size) != size) {
|
if (file.Read(reinterpret_cast<uint8 *> (&header), size) != size) {
|
||||||
printf("Error reading from file\n");
|
printf("Error: Unable to read the Be bitmap header.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
file.Unset();
|
||||||
|
// I don't need the file anymore
|
||||||
|
|
||||||
// convert to host byte order
|
// convert to host byte order
|
||||||
if (swap_data(B_UINT32_TYPE, &header, sizeof(TranslatorBitmap),
|
if (swap_data(B_UINT32_TYPE, &header, sizeof(TranslatorBitmap),
|
||||||
B_SWAP_BENDIAN_TO_HOST) != B_OK) {
|
B_SWAP_BENDIAN_TO_HOST) != B_OK) {
|
||||||
printf("Unable to swap byte order\n");
|
printf("Error: Unable to swap byte order\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("bits header for: %s\n", filepath);
|
printf("Be bitmap (\"bits\") header for: %s\n\n", filepath);
|
||||||
|
|
||||||
printf("width: %d\n",
|
const uint32 kbitsmagic = 0x62697473UL;
|
||||||
static_cast<int>(header.bounds.Width() + 1));
|
// in ASCII, this number looks like "bits"
|
||||||
printf("height: %d\n",
|
printf("magic number: 0x%.8lx ", header.magic);
|
||||||
|
if (header.magic == kbitsmagic)
|
||||||
|
printf("(valid)\n");
|
||||||
|
else
|
||||||
|
printf("(INVALID, should be: 0x%.8lx)\n",
|
||||||
|
kbitsmagic);
|
||||||
|
printf("bounds: (%f, %f, %f, %f)\n",
|
||||||
|
header.bounds.left, header.bounds.top,
|
||||||
|
header.bounds.right, header.bounds.bottom);
|
||||||
|
printf("dimensions: %d x %d\n",
|
||||||
|
static_cast<int>(header.bounds.Width() + 1),
|
||||||
static_cast<int>(header.bounds.Height() + 1));
|
static_cast<int>(header.bounds.Height() + 1));
|
||||||
|
|
||||||
printf("rowBytes: %u\n",
|
printf("bytes per row: %u\n",
|
||||||
static_cast<unsigned int>(header.rowBytes));
|
static_cast<unsigned int>(header.rowBytes));
|
||||||
|
|
||||||
// print out colorspace if it matches an item in the list
|
// print out colorspace if it matches an item in the list
|
||||||
@@ -132,15 +145,15 @@ PrintBitsInfo(const char *filepath)
|
|||||||
int32 i;
|
int32 i;
|
||||||
for (i = 0; i < kncolorspaces; i++) {
|
for (i = 0; i < kncolorspaces; i++) {
|
||||||
if (header.colors == colorspaces[i].id) {
|
if (header.colors == colorspaces[i].id) {
|
||||||
printf("colors: %s\n", colorspaces[i].name);
|
printf("color space: %s\n", colorspaces[i].name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == kncolorspaces)
|
if (i == kncolorspaces)
|
||||||
printf("colors: Unknown (0x%.8lx)\n",
|
printf("color space: Unknown (0x%.8lx)\n",
|
||||||
static_cast<unsigned long>(header.colors));
|
static_cast<unsigned long>(header.colors));
|
||||||
|
|
||||||
printf("dataSize: %u\n",
|
printf("data size: %u\n",
|
||||||
static_cast<unsigned int>(header.dataSize));
|
static_cast<unsigned int>(header.dataSize));
|
||||||
} else
|
} else
|
||||||
printf("Error opening %s\n", filepath);
|
printf("Error opening %s\n", filepath);
|
||||||
|
|||||||
Reference in New Issue
Block a user