[cairo] Re: Embeding JPG in PDF
Bill Spitzak
spitzak at d2.com
Fri Jan 12 20:40:21 PST 2007
Pierre wrote:
> I fail to see a more efficient way to embed images (png, jpeg or GIF
> work) than reading 500-1024 bytes, fetch the info and store the
> complete binary data in the PDF, there is no expensive operation
> except the IO part if the data is a file.
I agree. I think what is being proposed is a way to make that efficiency
automatically happen without the program having to know about the
special capabilities of pdf files. So this code will imbed the jpeg
image into the stream without compressing or decompressing it:
pattern = cairo_image_pattern_create("foo.jpg");
cairo_set_source(pattern); cairo_fill(...);
While your proposal requires a program to do this if it wants to use the
same code to draw both on the screen and in a pdf:
if (writing_pdf) {
pdf_surface_draw_jpg("foo.jpg");
} else {
// we are not drawing a pdf
pattern = cairo_image_pattern_create("foo.jpg");
cairo_set_source(pattern); cairo_fill(...);
}
More information about the cairo
mailing list