Re: Include bitmap in ipe XML file
Otfried Cheong <[email protected]>
| Newsgroups | gmane.comp.graphics.ipe.general |
|---|---|
| Organization | Ipe Inc. |
| Message-ID | <[email protected]> |
> Now when I got everything aligned I thought to include background > image for reference (which I previously process to extract certain > features as marks) My problem is that it seems I can't include image > as file path, but I need to encode it (filter FlateDecode) and hexify > then store inside XML file. For that purpose I used zlib module > compression, on png image binary data, but encoded content is not the > same as content saved from ipe (if I insert same image from ipe GUI > and save as ipe XML). Header seems same/similar, but not the stream > and as expected ipe can't read my generated file. The contents of the <bitmap> or <image> element must be the actual pixel data (not a PNG file contents). Assuming a color image, you need to dump the pixel values, starting at the top left, going row by row, until the bottom right. You don't need to compress or base64-encode, just dump the values in hexadecimal (so six hexadecimal digits are one RRGGBB pixel). You can include spaces or new-lines, they are ignored. E.g. <bitmap id="1" width="10" height="10" ColorSpace="DeviceRGB" BitsPerComponent="8"> 7a3400000000ff0000ff0000aa3478.... </bitmap> This syntax is for Ipe 7, but I'm pretty sure it did not change between Ipe 6 and Ipe 7. Definitely the main point was the same: don't set a filter, and include the image contents in hexadecimal (Base-64 encoding was added in Ipe 7.0.5). And of course Ipe 6 is really outdated now - it got obsolete in 2009... Is there any reason why you don't move to Ipe 7? Cheers, Otfried