Share

Haru Free PDF Library

Tracker: Bugs

5 Fatal Error in HPDF_ImageGetColorSpace for indexed images - ID: 1837826
Last Update: Comment added ( tony2001 )

When referencing an indexed image, HPDF_DICT_ITEM_UNEXPECTED_TYPE is
returned because the ColorSpace is stored as an Array instead of as a Name.
Here's the repair:

HPDF_EXPORT(const char*)
HPDF_Image_GetColorSpace (HPDF_Image image)
{
HPDF_Name n;
HPDF_PTRACE ((" HPDF_Image_GetColorSpace\n"));

n = HPDF_Dict_GetItem (image, "ColorSpace", HPDF_OCLASS_NAME);

if (!n) {
// If there's no item, we need to check for paletted a colorspace,

// which is stored as an array rather than as a name.

HPDF_Array a;

// We have an active error flag that'll haunt us if we don't reset

HPDF_Error_Reset(image->error);

// For paletted images, we actually have an array instead with the

// colorspace name in the first slot.

a = HPDF_Dict_GetItem (image, "ColorSpace", HPDF_OCLASS_ARRAY);
n = HPDF_Array_GetItem (a, 0, HPDF_OCLASS_NAME);
}

if (!n) {
HPDF_CheckError (image->error);
return NULL;
}

return n->value;
}


Jeremy J. Sydik ( jsydik ) - 2007-11-25 00:35

5

Closed

None

Nobody/Anonymous

None

None

Public


Comment ( 1 )




Date: 2008-04-22 11:04
Sender: tony2001Project Admin


Fixed in GIT repository.


Log in to comment.

Attached File

No Files Currently Attached

Changes ( 2 )

Field Old Value Date By
status_id Open 2008-04-22 11:04 tony2001
close_date - 2008-04-22 11:04 tony2001