How do I invert colors when extracting an embedded PDF image?


I need to extract some tif images from a PDF files with your library,
when i extract this PDF, the tif file appears with black and white
reverse. It works well with color tif.

                PDFDoc one_pdf = new PDFDoc(tb_pdf.Text);
                PageIterator page_end = one_pdf.PageEnd();
                PageIterator page_begin = one_pdf.PageBegin();
                ElementReader pdfreader = new ElementReader();
                PageIterator itr,itr2;
    for (itr = page_begin; itr != page_end; itr.Next())
                    Element pdfelement;
                    while ((pdfelement = pdfreader.Next()) != null)
                        switch (pdfelement.GetType())
                             case Element.Type.e_image:
                                   string fname = [my_output files
path] + image_counter;
                                  pdftron.PDF.Image image = new

Regarding the problem of inverted tiff, you could set Decode array
just before exporting the TIF. For example,

pdftron.PDF.Image image = new

pdftron.SDF.Obj dec = Obj.CreateArray();
// Invert the following two lines to invert the color in the output
image.GetSDFObj().Put("Decode", dec);


... erase Decode from image dictionary ?

Please keep in mind that the number of entries in the decode array
should be two times of the number of color components in the image
color space (so the above code assumes that the image is monochrome or
grayscale). This way it is possible to invert (or adjust) each color
channel separately.