pdfbox-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tilman Hausherr (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
Date Fri, 27 Jun 2014 06:03:25 GMT

    [ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14045578#comment-14045578
] 

Tilman Hausherr commented on PDFBOX-1915:
-----------------------------------------

I see you've been active with refactoring, this is good :-)

Yes the javadocs should be done too. It doesn't have to be long, but it should be a summary
of whats being done / how it is being used by other classes if it is an interface or an abstract
class. Nobody likes to do it, but the more you wait, the more annoying it becomes to do, so
don't wait :-)

Private classes are not required to have a javadoc, but they should have an explanation if
it isn't obvious from the code. Or at least a hint of whats being done. E.g. " getLen" =>
length of a line. "isEdgeALine" -> would like to know.

If you used a wikipedia article, or an online paper as help, include the link where applicable.
I couldn't have done types 1, 4, 5 without wikipedia and at one university course resource
:-)

- CoordinateColorPair.java: classes that are used only by you don't have to be public. Just
leave out the keyword "public".
- PatchMeshesShadingContext.java  readPatch(): if I remember this correctly, an EOF at that
place is a bug in the source file (the flag was read successfully but not the rest), thus
LOG.ERROR.
- that "decode" line you commented out: just remove it
- setLevel: this isn't a setter, it isn't a getter, I suggest you name it "calculateLevel"
or whatever. I assume this is what we discussed about here, i.e. you're making a decision
how far you'll chop the patch into triangles depending on the size of the patch.
- remove classes that have a comment "This class is not used" :-) Just delete them.

I'll run the code tonight and/or this weekend and give more feedback.

https://www.youtube.com/watch?v=TiqDqd-1pwU
watch at 29:00 he shows the patch on the top right of the file TENSOR.PDF, and it seems you
did the correct implementation :-)

The stuff at 22:00 is also about shading, but I feel that this goes over the scope of this
project. I don't even know if we support "knockout transparency groups", we just started with
transparency groups a week ago or so.

> 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: CIB-coons-vs-tensormesh.pdf, CIB-coonsmesh.pdf, CONICAL.pdf, GWG060_Shading_x1a.pdf,
GWG060_Shading_x1a_1.png, HSBWHEEL.pdf, McAfee-ShadingType7.pdf, Shadingtype6week1.pdf, TENSOR.pdf,
XYZsweep.pdf, _gwg060_shading_x1a.pdf-1.png, _mcafee-shadingtype7.pdf-1.png, 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, crestron-p9.pdf, eci_altona-test-suite-v2_technical_H.pdf,
failedTest.rar, lamp_cairo.pdf, lamp_cairo7_0.png, lamp_cairo7_1.png, lamp_cairo7_1.png, lineRasterization.jpg,
mcafeeU5.pdf, mcafeeU5_1.png, mcafeeu5.pdf-1.png, pass4FlagTest.rar, patchCases.jpg, patchMap.jpg,
shading6ContourTest.rar, shading6Done.rar, shading7.rar, tensor-nofunction-RGB.pdf, tensor-nofunction-RGB.ps,
tensor-nofunction-RGB_1.png, tensor4-nofunction.pdf, tensor4-nofunction.ps, tensor4-nofunction_1.png,
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)

Mime
View raw message