[
https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Shaola Ren updated PDFBOX-1915:
-------------------------------
Attachment: shading7.rar
1. rendering correct images: asy-coons-but-really-tensor7.pdf, asy-tensor7.pdf,
TENSOR7.pdf
the common characters of these files are, each image has a single data object
stream, color space is DeviceRGB
2. rendering part of the whole file: McAfee-ShadingType7.pdf
this file is made of several shading type 2 image and 1 shading type 7 image,
the shading type 7 is not converted by the program
in a usual file the parameter sequence is like this:
10 0 obj
<</ShadingType 7
/ColorSpace/DeviceRGB
/Decode[-16384
16384
-16384
16384
0
1
0
1
0
1]
/BitsPerCoordinate 24
/BitsPerComponent 16
/BitsPerFlag 8/Length 121>>stream
... endstream
endobj
in this file:
18 0 obj
<<
/AntiAlias false
/BitsPerComponent 8
/BitsPerCoordinate 32
/BitsPerFlag 8
/ColorSpace /DeviceCMYK
/Decode [1500.39 1711.32 -2589.48 -2378.55 0.0 1.0 0.0 1.0 0.0 1.0
0.0 1.0]
/Filter /FlateDecode
/Length 64760
/ShadingType 7
>>
stream ... endstream
endobj
when "ShadingType 7" is not at the beginning, the software has problem to deal
with the corresponding data, the shading type 2 part has a similar situation,
this may explain why the converted image lost the red top bar and the correct
color of the letters in the gray area
when testing this file, the program throws this message:
"org.apache.pdfbox.util.PDFStreamEngine processOperator INFO:
unsupported/disabled operation: BDC"
3. with color problems: XYZsweep7.pdf
the color space of this file is "ColorSpace 9 0 R", I think what I did in the
shading package is right, there must be some problem in the interpretation of
the ColorSpace.
when testing this file, the program throus this message:
"org.apache.pdfbox.util.PDFStreamEngine processOperator INFO:
unsupported/disabled operation: i"
4. cannot get image: lamp_cairo7.pdf
an file combined by many shading type 7 data streams, the software cannot work
correctly here
Now, shading type 7 and shading type 6 have some duplicated code, I will create
several shared classes to remove these duplicates.
> Implement shading with Coons and tensor-product patch meshes
> ------------------------------------------------------------
>
> Key: PDFBOX-1915
> URL: https://issues.apache.org/jira/browse/PDFBOX-1915
> Project: PDFBox
> Issue Type: Improvement
> Components: Rendering
> Affects Versions: 1.8.5, 1.8.6, 2.0.0
> Reporter: Tilman Hausherr
> Assignee: Shaola Ren
> Labels: graphical, gsoc2014, java, math, shading
> Fix For: 2.0.0
>
> Attachments: CONICAL.pdf, GWG060_Shading_x1a.pdf, HSBWHEEL.pdf,
> McAfee-ShadingType7.pdf, Shadingtype6week1.pdf, TENSOR.pdf, XYZsweep.pdf,
> asy-coons-but-really-tensor.pdf, asy-tensor-rainbow.pdf, asy-tensor.pdf,
> coons-function.pdf, coons-function.ps, coons-nofunction-CMYK.pdf,
> coons-nofunction-CMYK.ps, coons-nofunction-Duotone.pdf,
> coons-nofunction-Duotone.ps, coons-nofunction-Gray.pdf,
> coons-nofunction-Gray.ps, coons-nofunction-RGB.pdf, coons-nofunction-RGB.ps,
> coons2-function.pdf, coons2-function.ps, coons4-function.ps,
> eci_altona-test-suite-v2_technical_H.pdf, lamp_cairo.pdf, pass4FlagTest.rar,
> patchCases.jpg, patchMap.jpg, shading6ContourTest.rar, shading6Done.rar,
> shading7.rar, tensor-nofunction-RGB.pdf, tensor-nofunction-RGB.ps,
> updateshading6ContourTest.rar
>
>
> Of the seven shading methods described in the PDF specification, type 6
> (Coons patch meshes) and type 7 (Tensor-product patch meshes) haven't been
> implemented. I have done type 1, 4 and 5, but I don't know the math for type
> 6 and 7. My math days are decades away.
> Knowledge prerequisites:
> - java, although you don't have to be a java ace, just feel confortable
> - math: you should know what "cubic Bézier curves", "Degenerate Bézier
> curves", "bilinear interpolation", "tensor-product", "affine transform
> matrix" and "Bernstein polynomials" are, or be able to learn it
> - maven (basic)
> - svn (basic)
> - an IDE like Netbeans or Eclipse or IntelliJ (basic)
> - ideally, you are either a math student who likes to program, or a computer
> science student who is specializing in graphics.
> A first look at PDFBOX: try the command utility here:
> https://pdfbox.apache.org/commandline/#pdfToImage
> and use your favorite PDF, or the PDFs mentioned in PDFBOX-615, these have
> the shading types that are already implemented.
> Some simple source code to convert to images:
> String filename = "blah.pdf";
> PDDocument document = PDDocument.loadNonSeq(new File(filename), null);
> List<PDPage> pdPages = document.getDocumentCatalog().getAllPages();
> int page = 0;
> for (PDPage pdPage : pdPages)
> {
> ++page;
> BufferedImage bim = RenderUtil.convertToImage(pdPage,
> BufferedImage.TYPE_BYTE_BINARY, 300);
> ImageIO.write(bim, "png", new File(filename+page+".png"));
> }
> document.close();
> You are not starting from scratch. The implementation of type 4 and 5 shows
> you how to read parameters from the PDF and set the graphics. You don't have
> to learn the complete PDF spec, only 15 pages related to the two shading
> types, and 6 pages about shading in general. The PDF specification is here:
> http://www.adobe.com/devnet/pdf/pdf_reference.html
> The tricky parts are:
> - decide whether a point(x,y) is inside or outside a patch
> - decide the color of a point within the patch
> To get an idea about the code, look at the classes GouraudTriangle,
> GouraudShadingContext, Type4ShadingContext and Vertex here
> https://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/
> or download the whole project from the repository.
> https://pdfbox.apache.org/downloads.html#scm
> If you want to see the existing code in the debugger with a Gouraud shading,
> try this file:
> http://asymptote.sourceforge.net/gallery/Gouraud.pdf
> Testing:
> I have attached several example PDFs. To see which one has which shading,
> open them with an editor like NOTEPAD++, and search for "/ShadingType"
> (without the quotes). If your images are rendering like the example PDFs,
> then you were successful.
> Optional:
> Review and optimize the complete shading package for speed; implement cubic
> spline interpolation for type 0 (sampled) functions (that one is really
> low-low priority, see details by looking up "cubic spline interpolation" in
> the PDF spec, which tells that it is disregarded in printing, and I don't
> have a test PDF).
> Mentor: Tilman Hausherr (European timezone, languages: german, english,
> french)
--
This message was sent by Atlassian JIRA
(v6.2#6252)