Fix some issues with the core file writing code.

Add test images to the unit tests.
This commit is contained in:
Michael R Sweet
2021-05-28 10:41:21 -04:00
parent 9cf024c1ce
commit fb853dadda
7 changed files with 103 additions and 15 deletions

View File

@@ -827,11 +827,35 @@ pdfioPageDictAddImage(
const char *name, // I - Image name
pdfio_obj_t *obj) // I - Image object
{
(void)dict;
(void)name;
(void)obj;
pdfio_dict_t *resources; // Resource dictionary
pdfio_dict_t *xobject; // XObject dictionary
return (false);
// Range check input...
if (!dict || !name || !obj)
return (false);
// Get the images dictionary...
if ((resources = pdfioDictGetDict(dict, "Resources")) == NULL)
{
if ((resources = pdfioDictCreate(dict->pdf)) == NULL)
return (false);
if (!pdfioDictSetDict(dict, "Resources", resources))
return (false);
}
if ((xobject = pdfioDictGetDict(resources, "XObject")) == NULL)
{
if ((xobject = pdfioDictCreate(dict->pdf)) == NULL)
return (false);
if (!pdfioDictSetDict(resources, "XObject", xobject))
return (false);
}
// Now set the image reference in the images resource dictionary and return...
return (pdfioDictSetObject(xobject, name, obj));
}