[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14092481#comment-14092481 ] Shaola Ren commented on PDFBOX-1915: Thanks for your trust, and thank you for giving me this opportunity to touch a field which is beyond my research but is a great interest of mine. I appreciated all the help that you and other people gave me. > 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, 1.8.7, 2.0.0 >Reporter: Tilman Hausherr >Assignee: Shaola Ren > Labels: graphical, gsoc2014, java, math, shading > Fix For: 1.8.7, 2.0.0 > > Attachments: CIB-coons-vs-tensormesh.pdf, CIB-coonsmesh.pdf, > CONICAL.pdf, DECAHED.pdf, GWG060_Shading_x1a.pdf, GWG060_Shading_x1a_1.png, > HSBWHEEL.pdf, Kommunikationsbedingungen-Einlagen_FIDOR-Bank.pdf, > LATTICE1.pdf, LATTICE2.pdf, McAfee-ShadingType7.pdf, > Shading2Function2LargeDomain.pdf, Shading2Function2LargeDomain.pdf-1-bad.png, > Shading2Function2LargeDomain.pdf-1-good.png, Shading2Function2LargeDomain.ps, > Shadingtype6week1.pdf, TENSOR.pdf, TRITYP4.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, > axsh02.pdf, axsh02_1_withBBox.png, axsh02_1_withoutBBox.png, ch14.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_1-old.png, eci_1.png, eci_altona-test-suite-v2_technical_H.pdf, > example_030.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, pattern-shading-2-4-idMatrix.pdf, 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, > type45.pdf, 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 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 reposito
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14088860#comment-14088860 ] Shaola Ren commented on PDFBOX-1915: Take your time. I tried to use the floodfill algorithm to generate the points inside a triangle for type 4 and 5 shading, theoretically when knowing the edge and the seed point, it should be faster. But for our current situation, marking out the edge of a triangle consumes more time, so the performance is not good as expected. That part of code is still in the GouraudShadingContext (https://bitbucket.org/xinshu/pdfbox) but commented out, please don't waste time on it, I left them there as it may be convenient for me to make some further change. > 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, DECAHED.pdf, GWG060_Shading_x1a.pdf, GWG060_Shading_x1a_1.png, > HSBWHEEL.pdf, Kommunikationsbedingungen-Einlagen_FIDOR-Bank.pdf, > LATTICE1.pdf, LATTICE2.pdf, McAfee-ShadingType7.pdf, > Shading2Function2LargeDomain.pdf, Shading2Function2LargeDomain.pdf-1-bad.png, > Shading2Function2LargeDomain.pdf-1-good.png, Shading2Function2LargeDomain.ps, > Shadingtype6week1.pdf, TENSOR.pdf, TRITYP4.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, > axsh02.pdf, axsh02_1_withBBox.png, axsh02_1_withoutBBox.png, ch14.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_1-old.png, eci_1.png, eci_altona-test-suite-v2_technical_H.pdf, > example_030.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, pattern-shading-2-4-idMatrix.pdf, 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, > type45.pdf, 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 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 > - de
[jira] [Updated] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Shaola Ren updated PDFBOX-1915: --- Attachment: eci_1.png eci_1-old.png I didn't mean there is a difference in my before and after code, I meant your code gave different result from mine for the eci.pdf, but the same for all other type 4 & 5 shading test files. the eci_1-old was got before I edited the type 4 & 5 shading, the eci_1 is got from my current code. The one rectangle lacked one corner in eci_1-old is type 4, the one below is type 5. > 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, DECAHED.pdf, GWG060_Shading_x1a.pdf, GWG060_Shading_x1a_1.png, > HSBWHEEL.pdf, Kommunikationsbedingungen-Einlagen_FIDOR-Bank.pdf, > LATTICE1.pdf, LATTICE2.pdf, McAfee-ShadingType7.pdf, > Shading2Function2LargeDomain.pdf, Shading2Function2LargeDomain.pdf-1-bad.png, > Shading2Function2LargeDomain.pdf-1-good.png, Shading2Function2LargeDomain.ps, > Shadingtype6week1.pdf, TENSOR.pdf, TRITYP4.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, > axsh02.pdf, axsh02_1_withBBox.png, axsh02_1_withoutBBox.png, ch14.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_1-old.png, eci_1.png, eci_altona-test-suite-v2_technical_H.pdf, > example_030.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, pattern-shading-2-4-idMatrix.pdf, 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, > type45.pdf, 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 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 > h
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14086060#comment-14086060 ] Shaola Ren commented on PDFBOX-1915: Thanks. There should be a bug in the original code for type 4 shading, the type 4 rectangle in the eci file lacks one corner, which is fixed in the hashtable version, but as these two versions use different sequence to generate the trianglelist, I don't know where the bug happens in the original code. Besides the BBox boundary clipping, I also made some change for type 6 & 7 shading, the reason is stated in the item 2 in type45.pdf. Yes, I know the problem for the the Kerstin Upmeyer frog file, which I mentioned in the item 5 in type45.pdf, however not specifically, this case also happens when rendering the lamp_cairo7.pdf at 300 dpi. It's kind of hard to fix for me now, to fix this I think a better mesh generating algorithm or a better triangle's points generating algorithm is needed or both. But, I will think about it. Thanks for your suggestion to prepare the stuff to be uploaded to google, I'll take it. > 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, DECAHED.pdf, GWG060_Shading_x1a.pdf, GWG060_Shading_x1a_1.png, > HSBWHEEL.pdf, Kommunikationsbedingungen-Einlagen_FIDOR-Bank.pdf, > LATTICE1.pdf, LATTICE2.pdf, McAfee-ShadingType7.pdf, > Shading2Function2LargeDomain.pdf, Shading2Function2LargeDomain.pdf-1-bad.png, > Shading2Function2LargeDomain.pdf-1-good.png, Shading2Function2LargeDomain.ps, > Shadingtype6week1.pdf, TENSOR.pdf, TRITYP4.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, > axsh02.pdf, axsh02_1_withBBox.png, axsh02_1_withoutBBox.png, ch14.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, example_030.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, > pattern-shading-2-4-idMatrix.pdf, 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, type45.pdf, 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 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 f
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14085763#comment-14085763 ] Shaola Ren commented on PDFBOX-1915: We are kind of doing duplicated work now, and as it's approaching the suggested pencils down date Aug. 11, I think I should stop working on this project at some moment, although there is no need to write additional tests and documents which are suggested on the melange website for the left time. The main aim of this project is more or less achieved, I think, the optional task is vague, there is always space to make a code better. I'd like to set this thread as resolved at the end of this project, however, you can have your own decision. If there are new problems coming out, I think creating new issues is better than working under this thread, and this will also give other people opportunities to contribute to this software on this topic. And hopefully, I achieved the passed criteria, which I think I should. > 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, DECAHED.pdf, GWG060_Shading_x1a.pdf, GWG060_Shading_x1a_1.png, > HSBWHEEL.pdf, Kommunikationsbedingungen-Einlagen_FIDOR-Bank.pdf, > LATTICE1.pdf, LATTICE2.pdf, McAfee-ShadingType7.pdf, > Shading2Function2LargeDomain.pdf, Shading2Function2LargeDomain.pdf-1-bad.png, > Shading2Function2LargeDomain.pdf-1-good.png, Shading2Function2LargeDomain.ps, > Shadingtype6week1.pdf, TENSOR.pdf, TRITYP4.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, > axsh02.pdf, axsh02_1_withBBox.png, axsh02_1_withoutBBox.png, ch14.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, example_030.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, > pattern-shading-2-4-idMatrix.pdf, 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, type45.pdf, 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 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
[jira] [Commented] (PDFBOX-2117) AxialShadingContext is slow
[ https://issues.apache.org/jira/browse/PDFBOX-2117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14082093#comment-14082093 ] Shaola Ren commented on PDFBOX-2117: Thanks for all those discussion, I reread the document and code, inputValue is not t, its range is always 0 to 1, we should keep the simple inputValue * length form, the very first version. Sorry about my last two comments, everything is clear now, a misunderstand of inputValue before. > AxialShadingContext is slow > --- > > Key: PDFBOX-2117 > URL: https://issues.apache.org/jira/browse/PDFBOX-2117 > Project: PDFBox > Issue Type: Sub-task > Components: Rendering >Affects Versions: 1.8.6, 1.8.7, 2.0.0 >Reporter: Petr Slaby >Assignee: Shaola Ren > Labels: shading, shadingpattern > Fix For: 2.0.0 > > Attachments: 01_MTEXT_CS6.pdf, AxialShading.patch, > AxialShading1.patch, AxialShadingContext.java.getrgbimage, > GWG061_Shading_x1a.pdf, GWG061_Shading_x1a.pdf-1.png, > GWG061_Shading_x1a.pdf-1.png-diff.png, PDFBOX-2117-068519-ShadingType3.pdf, > PDFBOX-2117-068519.pdf, PDFBOX-2117-068519.pdf-2-bad.png, > PDFBOX-2117-068519.pdf-2-good.png, Shading2Function2.pdf, > Shading2Function2.ps, Shading2Function2domain3.pdf, > Shading2Function2text.pdf, asy-shade.pdf, > bad_pdfbox-2117-068519-shadingtype3.pdf-1.png, color_gradient.pdf, > good_pdfbox-2117-068519-shadingtype3.pdf-1.png, shading_pattern.pdf > > > AxialShadingContext#getRaster() is on top of profiler hot spots in documents > that use an axial shading. Inside it, the slowest part is calling > PDColorSpaceRGB#toRGB() and PDFunctionType3#eval() (in this order). > -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (PDFBOX-2117) AxialShadingContext is slow
[ https://issues.apache.org/jira/browse/PDFBOX-2117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14081807#comment-14081807 ] Shaola Ren commented on PDFBOX-2117: Sorry, I thought it a little bit more, if I make the decision, I will take int key = (int) ((inputValue - domain[0]) * longestDistance / d1d0); and int key = (int) ((inputValue - domain[0]) * axialLength / d1d0); as they are just solutions of t = domain[0] + d1d0 * i / (float)longestDistance and t = domain[0] + d1d0 * i / (float)axialLength respectively, those two are used in the calcColorTable, key is corresponding to i. When the domain is 0 to 1, the above key is correct, and when the domain is not 0 to 1, the above key is still correct, no matter what is changed, the above form of key is the original and always correct one. In my first version, I just forgot to consider the case that t may not start with 0 and end with 1, it's a fault, and it just passed all the previous test cases as they all happened to have 0 to 1 domain, then the form of key simplified to inputValue * length. > AxialShadingContext is slow > --- > > Key: PDFBOX-2117 > URL: https://issues.apache.org/jira/browse/PDFBOX-2117 > Project: PDFBox > Issue Type: Sub-task > Components: Rendering >Affects Versions: 1.8.6, 1.8.7, 2.0.0 >Reporter: Petr Slaby >Assignee: Shaola Ren > Labels: shading, shadingpattern > Fix For: 2.0.0 > > Attachments: 01_MTEXT_CS6.pdf, AxialShading.patch, > AxialShading1.patch, AxialShadingContext.java.getrgbimage, > GWG061_Shading_x1a.pdf, GWG061_Shading_x1a.pdf-1.png, > GWG061_Shading_x1a.pdf-1.png-diff.png, PDFBOX-2117-068519.pdf, > PDFBOX-2117-068519.pdf-2-bad.png, PDFBOX-2117-068519.pdf-2-good.png, > Shading2Function2.pdf, Shading2Function2.ps, Shading2Function2text.pdf, > asy-shade.pdf, color_gradient.pdf, shading_pattern.pdf > > > AxialShadingContext#getRaster() is on top of profiler hot spots in documents > that use an axial shading. Inside it, the slowest part is calling > PDColorSpaceRGB#toRGB() and PDFunctionType3#eval() (in this order). > -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (PDFBOX-2117) AxialShadingContext is slow
[ https://issues.apache.org/jira/browse/PDFBOX-2117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14081772#comment-14081772 ] Shaola Ren commented on PDFBOX-2117: That's fine, it's just a different way to deal with the domain values, and hope everything is consistent with each other now. > AxialShadingContext is slow > --- > > Key: PDFBOX-2117 > URL: https://issues.apache.org/jira/browse/PDFBOX-2117 > Project: PDFBox > Issue Type: Sub-task > Components: Rendering >Affects Versions: 1.8.6, 1.8.7, 2.0.0 >Reporter: Petr Slaby >Assignee: Shaola Ren > Labels: shading, shadingpattern > Fix For: 2.0.0 > > Attachments: 01_MTEXT_CS6.pdf, AxialShading.patch, > AxialShading1.patch, AxialShadingContext.java.getrgbimage, > GWG061_Shading_x1a.pdf, GWG061_Shading_x1a.pdf-1.png, > GWG061_Shading_x1a.pdf-1.png-diff.png, PDFBOX-2117-068519.pdf, > PDFBOX-2117-068519.pdf-2-bad.png, PDFBOX-2117-068519.pdf-2-good.png, > Shading2Function2.pdf, Shading2Function2.ps, Shading2Function2text.pdf, > asy-shade.pdf, color_gradient.pdf, shading_pattern.pdf > > > AxialShadingContext#getRaster() is on top of profiler hot spots in documents > that use an axial shading. Inside it, the slowest part is calling > PDColorSpaceRGB#toRGB() and PDFunctionType3#eval() (in this order). > -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14081761#comment-14081761 ] Shaola Ren commented on PDFBOX-1915: That's because most of the test files don't have this optional field BBox except the file I attached. I thought you wouldn't commit it now as all other shading types need to have this change as well and there should be more changes, those small commits create too many separate issues which could be grouped together and be committed once. Anyway, thanks to commit this change. > 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, DECAHED.pdf, GWG060_Shading_x1a.pdf, GWG060_Shading_x1a_1.png, > HSBWHEEL.pdf, LATTICE1.pdf, LATTICE2.pdf, McAfee-ShadingType7.pdf, > Shadingtype6week1.pdf, TENSOR.pdf, TRITYP4.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, > axsh02.pdf, axsh02_1_withBBox.png, axsh02_1_withoutBBox.png, ch14.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, example_030.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, > pattern-shading-2-4-idMatrix.pdf, 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, type45.pdf, 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 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 co
[jira] [Updated] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Shaola Ren updated PDFBOX-1915: --- Attachment: axsh02_1_withoutBBox.png axsh02_1_withBBox.png axsh02.pdf All of the shading context classes don't consider the BBox, the attached axsh02.pdf could not be rendered correctly without considering BBox, see the two attached image axsh02_1_withBBox and axsh02_1_withoutBBox. This means I need to apply the similar change to other shading context besides type 2. Another potential problem for type 6 & 7 is that if something happens like the item 2 in the type45.pdf, the device bound needs to be passed to the context class. > 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, DECAHED.pdf, GWG060_Shading_x1a.pdf, GWG060_Shading_x1a_1.png, > HSBWHEEL.pdf, LATTICE1.pdf, LATTICE2.pdf, McAfee-ShadingType7.pdf, > Shadingtype6week1.pdf, TENSOR.pdf, TRITYP4.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, > axsh02.pdf, axsh02_1_withBBox.png, axsh02_1_withoutBBox.png, ch14.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, example_030.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, > pattern-shading-2-4-idMatrix.pdf, 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, type45.pdf, 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 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/
[jira] [Commented] (PDFBOX-2117) AxialShadingContext is slow
[ https://issues.apache.org/jira/browse/PDFBOX-2117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14079018#comment-14079018 ] Shaola Ren commented on PDFBOX-2117: I didn't synchronize the my local code with the most updated trunk code, my local code cannot even display the bullet contents. However, I suspected that the bad image is not caused by my calculation, I tested it with all the previous type 2 and 3 shading images that I have, it performs well. This problem may be caused by the way how other part of the software calling this type 3 shading class, as if another part of the software calls radialshadingcontext and that code was developed before I created the colorTable field and that code was designed to store some parameters from the radialshadingcontext instead of the whole instance, then those newly created data field may not be passed to the corresponding code, so the bad image does not have any type 3 shading image. > AxialShadingContext is slow > --- > > Key: PDFBOX-2117 > URL: https://issues.apache.org/jira/browse/PDFBOX-2117 > Project: PDFBox > Issue Type: Sub-task > Components: Rendering >Affects Versions: 1.8.6, 1.8.7, 2.0.0 >Reporter: Petr Slaby >Assignee: Shaola Ren > Labels: shading, shadingpattern > Fix For: 1.8.7, 2.0.0 > > Attachments: 01_MTEXT_CS6.pdf, AxialShading.patch, > AxialShading1.patch, AxialShadingContext.java.getrgbimage, > GWG061_Shading_x1a.pdf, GWG061_Shading_x1a.pdf-1.png, > GWG061_Shading_x1a.pdf-1.png-diff.png, PDFBOX-2117-068519.pdf, > PDFBOX-2117-068519.pdf-2-bad.png, PDFBOX-2117-068519.pdf-2-good.png, > Shading2Function2.pdf, Shading2Function2.ps, Shading2Function2text.pdf, > asy-shade.pdf, color_gradient.pdf, shading_pattern.pdf > > > AxialShadingContext#getRaster() is on top of profiler hot spots in documents > that use an axial shading. Inside it, the slowest part is calling > PDColorSpaceRGB#toRGB() and PDFunctionType3#eval() (in this order). > -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (PDFBOX-2117) AxialShadingContext is slow
[ https://issues.apache.org/jira/browse/PDFBOX-2117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14078841#comment-14078841 ] Shaola Ren commented on PDFBOX-2117: Yes, you are right, change the line 278 int key = (int) (inputValue * axialLength); to int key = (int) ((inputValue - domain[0]) * axialLength / d1d0); in AxialShadingContext and the line 371 int key = (int) (inputValue * longestDistance); to int key = (int) ((inputValue - domain[0]) * longestDistance / d1d0); in RadialShadingContext > AxialShadingContext is slow > --- > > Key: PDFBOX-2117 > URL: https://issues.apache.org/jira/browse/PDFBOX-2117 > Project: PDFBox > Issue Type: Sub-task > Components: Rendering >Affects Versions: 1.8.6, 1.8.7, 2.0.0 >Reporter: Petr Slaby >Assignee: Shaola Ren > Labels: shading, shadingpattern > Fix For: 1.8.7, 2.0.0 > > Attachments: 01_MTEXT_CS6.pdf, AxialShading.patch, > AxialShading1.patch, AxialShadingContext.java.getrgbimage, > GWG061_Shading_x1a.pdf, GWG061_Shading_x1a.pdf-1.png, > GWG061_Shading_x1a.pdf-1.png-diff.png, PDFBOX-2117-068519.pdf, > Shading2Function2.pdf, Shading2Function2.ps, Shading2Function2text.pdf, > asy-shade.pdf, color_gradient.pdf, shading_pattern.pdf > > > AxialShadingContext#getRaster() is on top of profiler hot spots in documents > that use an axial shading. Inside it, the slowest part is calling > PDColorSpaceRGB#toRGB() and PDFunctionType3#eval() (in this order). > -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Updated] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Shaola Ren updated PDFBOX-1915: --- Attachment: type45.pdf It's a long story to explain some issues clear, so I put them in this type45.pdf file, you can have a look at it. > 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, DECAHED.pdf, GWG060_Shading_x1a.pdf, GWG060_Shading_x1a_1.png, > HSBWHEEL.pdf, McAfee-ShadingType7.pdf, Shadingtype6week1.pdf, TENSOR.pdf, > TRITYP4.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, ch14.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, example_030.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, > pattern-shading-2-4-idMatrix.pdf, 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, type45.pdf, 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 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. > Opt
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14075844#comment-14075844 ] Shaola Ren commented on PDFBOX-1915: Thanks, bad news is good news, it is helpful to make the code better. However, there is no guarantee that I will always do the correct thing. > 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, DECAHED.pdf, GWG060_Shading_x1a.pdf, GWG060_Shading_x1a_1.png, > HSBWHEEL.pdf, McAfee-ShadingType7.pdf, Shadingtype6week1.pdf, TENSOR.pdf, > TRITYP4.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, ch14.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, example_030.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, > pattern-shading-2-4-idMatrix.pdf, 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 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 exa
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14075242#comment-14075242 ] Shaola Ren commented on PDFBOX-1915: I modified type 4 & 5 shading, for the eci file, type 4 gets right, type 5 performs a misordered problem, I will fix this later. I didn't write the corresponding java doc for those two types shading, they may need further change. For the doughnut image in the chap14, the performance is not improved, the reason is that the hash table can save time in one instance of a shading context, when the size of the triangle list in this shading context is small, the hash table doesn't have an obvious advantage over a simple arraylist. The doughnut image is composed by over 800 type 4 shading instances, each instance only contains a small data stream. Thus the time consumption is mostly from the frequent call of PDShadingType4, I think this is an issue outside the shading package, in order to reduce the rendering time for this doughnut image, modification in this shading context is not much helpful. For the eci file, I cannot simply locate the shading type for the rectangle has two thin stripes which are not correct now, there should be some problem in the corresponding shading, I'll work on this later as well. The code is updated in the usual place. > 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, > ch14.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, example_030.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 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 page
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14064814#comment-14064814 ] Shaola Ren commented on PDFBOX-1915: Thanks for writing all those tests. I am working on type 4&5 shading, they may need more changes. I may use my CoonsTriangle to substitute your GouraudTriangle, as the CoonsTriangle has more methods to deal with the degeneracy and is more suitable to do the pixel calculation. And then, I may change the name "CoonsTriangle" to "Trianlge" or "MeshTriangle" as it is actually a triangle or a degenerated triangle. Then the method to get the pixel table will be more or less similar to type 6&7 shading. > 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, > ch14.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, example_030.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 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
[jira] [Commented] (PDFBOX-2117) AxialShadingContext is slow
[ https://issues.apache.org/jira/browse/PDFBOX-2117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14063436#comment-14063436 ] Shaola Ren commented on PDFBOX-2117: Thanks. I noticed you mentioned diagonal shading in a previous comment, but not too sure what the special part of it. For this axial shading, the axial line can be in any direction, the method doesn't depend on a specific direction; the diagonal direction is only one case of it. > AxialShadingContext is slow > --- > > Key: PDFBOX-2117 > URL: https://issues.apache.org/jira/browse/PDFBOX-2117 > Project: PDFBox > Issue Type: Sub-task > Components: Rendering >Reporter: Petr Slaby >Assignee: Shaola Ren > Fix For: 2.0.0 > > Attachments: 01_MTEXT_CS6.pdf, AxialShading.patch, > AxialShading1.patch, AxialShadingContext.java.getrgbimage, > GWG061_Shading_x1a.pdf, GWG061_Shading_x1a.pdf-1.png, > GWG061_Shading_x1a.pdf-1.png-diff.png, Shading2Function2.pdf, > Shading2Function2.ps, Shading2Function2text.pdf, asy-shade.pdf, > color_gradient.pdf, shading_pattern.pdf > > > AxialShadingContext#getRaster() is on top of profiler hot spots in documents > that use an axial shading. Inside it, the slowest part is calling > PDColorSpaceRGB#toRGB() and PDFunctionType3#eval() (in this order). > -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (PDFBOX-2117) AxialShadingContext is slow
[ https://issues.apache.org/jira/browse/PDFBOX-2117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14062944#comment-14062944 ] Shaola Ren commented on PDFBOX-2117: maybe you can close this issue now, or I can close it at some moment. > AxialShadingContext is slow > --- > > Key: PDFBOX-2117 > URL: https://issues.apache.org/jira/browse/PDFBOX-2117 > Project: PDFBox > Issue Type: Sub-task > Components: Rendering >Reporter: Petr Slaby > Attachments: 01_MTEXT_CS6.pdf, AxialShading.patch, > AxialShading1.patch, AxialShadingContext.java.getrgbimage, > GWG061_Shading_x1a.pdf, GWG061_Shading_x1a.pdf-1.png, > GWG061_Shading_x1a.pdf-1.png-diff.png, Shading2Function2.pdf, > Shading2Function2.ps, Shading2Function2text.pdf, asy-shade.pdf, > color_gradient.pdf, shading_pattern.pdf > > > AxialShadingContext#getRaster() is on top of profiler hot spots in documents > that use an axial shading. Inside it, the slowest part is calling > PDColorSpaceRGB#toRGB() and PDFunctionType3#eval() (in this order). > -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (PDFBOX-2117) AxialShadingContext is slow
[ https://issues.apache.org/jira/browse/PDFBOX-2117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14062933#comment-14062933 ] Shaola Ren commented on PDFBOX-2117: Absolutely, for the radial shading, the color along the line passing the two centers of the two circles is stored. I have updated the code in my repository. I changed the hashmap to an array, and used an integer to indicate a RGB color value, to me, I prefer this version, however, you can decide whether to used this version or the previous one, I didn't deprecate the class ColorRGB now. Technically, I can use a 2D array to store the pixels' color instead of a hashmap in type 6&7 shading, but there are some other issues need to consider, like getting the image dimension, calculating a position shift when the shading area is only a small parts of the whole image. Some refactoring may possible to be done, which is a little bit dangerous, to me, I'd like to keep it as now. If have to, I'd like to do it at the very last as optimization of some other types shading is not done yet. > AxialShadingContext is slow > --- > > Key: PDFBOX-2117 > URL: https://issues.apache.org/jira/browse/PDFBOX-2117 > Project: PDFBox > Issue Type: Sub-task > Components: Rendering >Reporter: Petr Slaby > Attachments: 01_MTEXT_CS6.pdf, AxialShading.patch, > AxialShading1.patch, AxialShadingContext.java.getrgbimage, > GWG061_Shading_x1a.pdf, GWG061_Shading_x1a.pdf-1.png, > GWG061_Shading_x1a.pdf-1.png-diff.png, Shading2Function2.pdf, > Shading2Function2.ps, Shading2Function2text.pdf, asy-shade.pdf, > color_gradient.pdf, shading_pattern.pdf > > > AxialShadingContext#getRaster() is on top of profiler hot spots in documents > that use an axial shading. Inside it, the slowest part is calling > PDColorSpaceRGB#toRGB() and PDFunctionType3#eval() (in this order). > -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (PDFBOX-2117) AxialShadingContext is slow
[ https://issues.apache.org/jira/browse/PDFBOX-2117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14058777#comment-14058777 ] Shaola Ren commented on PDFBOX-2117: Cool, for this type 2 shading, an array is pretty enough, thanks, I'll make this change. > AxialShadingContext is slow > --- > > Key: PDFBOX-2117 > URL: https://issues.apache.org/jira/browse/PDFBOX-2117 > Project: PDFBox > Issue Type: Sub-task > Components: Rendering >Reporter: Petr Slaby > Attachments: 01_MTEXT_CS6.pdf, AxialShading.patch, > AxialShading1.patch, AxialShadingContext.java.getrgbimage, > GWG061_Shading_x1a.pdf, GWG061_Shading_x1a.pdf-1.png, > GWG061_Shading_x1a.pdf-1.png-diff.png, Shading2Function2.pdf, > Shading2Function2.ps, Shading2Function2text.pdf, asy-shade.pdf, > color_gradient.pdf, shading_pattern.pdf > > > AxialShadingContext#getRaster() is on top of profiler hot spots in documents > that use an axial shading. Inside it, the slowest part is calling > PDColorSpaceRGB#toRGB() and PDFunctionType3#eval() (in this order). > -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (PDFBOX-2117) AxialShadingContext is slow
[ https://issues.apache.org/jira/browse/PDFBOX-2117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14058717#comment-14058717 ] Shaola Ren commented on PDFBOX-2117: Re the diff image, that is possible, different calculation methods may create some variations, both should be taken as correct in my opinion. This case happens in the lamp_cairo7.pdf as well, when you compare the rendered image and the adobe view, you will see the rendered image is more smooth in some details. > AxialShadingContext is slow > --- > > Key: PDFBOX-2117 > URL: https://issues.apache.org/jira/browse/PDFBOX-2117 > Project: PDFBox > Issue Type: Sub-task > Components: Rendering >Reporter: Petr Slaby > Attachments: 01_MTEXT_CS6.pdf, AxialShading.patch, > AxialShading1.patch, AxialShadingContext.java.getrgbimage, > GWG061_Shading_x1a.pdf, GWG061_Shading_x1a.pdf-1.png, > GWG061_Shading_x1a.pdf-1.png-diff.png, Shading2Function2.pdf, > Shading2Function2.ps, Shading2Function2text.pdf, asy-shade.pdf, > color_gradient.pdf, shading_pattern.pdf > > > AxialShadingContext#getRaster() is on top of profiler hot spots in documents > that use an axial shading. Inside it, the slowest part is calling > PDColorSpaceRGB#toRGB() and PDFunctionType3#eval() (in this order). > -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (PDFBOX-2117) AxialShadingContext is slow
[ https://issues.apache.org/jira/browse/PDFBOX-2117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14058696#comment-14058696 ] Shaola Ren commented on PDFBOX-2117: Great, thank Petr. I'll take your suggestion. > AxialShadingContext is slow > --- > > Key: PDFBOX-2117 > URL: https://issues.apache.org/jira/browse/PDFBOX-2117 > Project: PDFBox > Issue Type: Sub-task > Components: Rendering >Reporter: Petr Slaby > Attachments: 01_MTEXT_CS6.pdf, AxialShading.patch, > AxialShading1.patch, AxialShadingContext.java.getrgbimage, > GWG061_Shading_x1a.pdf, GWG061_Shading_x1a.pdf-1.png, > GWG061_Shading_x1a.pdf-1.png-diff.png, Shading2Function2.pdf, > Shading2Function2.ps, Shading2Function2text.pdf, asy-shade.pdf, > color_gradient.pdf, shading_pattern.pdf > > > AxialShadingContext#getRaster() is on top of profiler hot spots in documents > that use an axial shading. Inside it, the slowest part is calling > PDColorSpaceRGB#toRGB() and PDFunctionType3#eval() (in this order). > -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (PDFBOX-2117) AxialShadingContext is slow
[ https://issues.apache.org/jira/browse/PDFBOX-2117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14058273#comment-14058273 ] Shaola Ren commented on PDFBOX-2117: in the getRaster(), this should be used int key = (int) Math.round((inputValue * axialLength)); not this int key = (int) (inputValue * axialLength); there may be some other changes before the final version, it's annoying to state out every item here. > AxialShadingContext is slow > --- > > Key: PDFBOX-2117 > URL: https://issues.apache.org/jira/browse/PDFBOX-2117 > Project: PDFBox > Issue Type: Sub-task > Components: Rendering >Reporter: Petr Slaby > Attachments: 01_MTEXT_CS6.pdf, AxialShading.patch, > AxialShading1.patch, AxialShadingContext.java.getrgbimage, > Shading2Function2.pdf, Shading2Function2.ps, Shading2Function2text.pdf, > asy-shade.pdf, color_gradient.pdf, shading_pattern.pdf > > > AxialShadingContext#getRaster() is on top of profiler hot spots in documents > that use an axial shading. Inside it, the slowest part is calling > PDColorSpaceRGB#toRGB() and PDFunctionType3#eval() (in this order). > -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (PDFBOX-2117) AxialShadingContext is slow
[ https://issues.apache.org/jira/browse/PDFBOX-2117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14058182#comment-14058182 ] Shaola Ren commented on PDFBOX-2117: Yes, what you said is right, I only need to calculate the color on the axial line. Yes, I only looked at the source code, don't have a specific test file, my changes are only in PDFunction, they are not that critical, a little bit more efficient, I think. Yes, it's a good idea to make the exponent N as a field of PDFunctionType2. All these changes in the function package won't make a big difference, however, I think it's worth to make those changes, I'll take your suggestion, thanks. There are no obvious flaw in type 2 shading, there is space to improve it, but the change may not be as big as we saw in type 6&7. > AxialShadingContext is slow > --- > > Key: PDFBOX-2117 > URL: https://issues.apache.org/jira/browse/PDFBOX-2117 > Project: PDFBox > Issue Type: Sub-task > Components: Rendering >Reporter: Petr Slaby > Attachments: 01_MTEXT_CS6.pdf, AxialShading.patch, > AxialShading1.patch, AxialShadingContext.java.getrgbimage, > Shading2Function2.pdf, Shading2Function2.ps, Shading2Function2text.pdf, > asy-shade.pdf, color_gradient.pdf, shading_pattern.pdf > > > AxialShadingContext#getRaster() is on top of profiler hot spots in documents > that use an axial shading. Inside it, the slowest part is calling > PDColorSpaceRGB#toRGB() and PDFunctionType3#eval() (in this order). > -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14057239#comment-14057239 ] Shaola Ren commented on PDFBOX-1915: Thanks. Hash table is a powerful tool when it is used in the right way. > 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, > ch14.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, example_030.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 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 > s
[jira] [Commented] (PDFBOX-2117) AxialShadingContext is slow
[ https://issues.apache.org/jira/browse/PDFBOX-2117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14056983#comment-14056983 ] Shaola Ren commented on PDFBOX-2117: I used the same technique as I did in type 6&7 shading, but different implements. To me, it's faster when rendering type 2 shading image. the repository https://bitbucket.org/xinshu/pdfbox.git is up to date (https://bitbucket.org/xinshu/pdfbox), for this type 2 shading, the code in AxialShadingContext and PDFunction is modified. > AxialShadingContext is slow > --- > > Key: PDFBOX-2117 > URL: https://issues.apache.org/jira/browse/PDFBOX-2117 > Project: PDFBox > Issue Type: Sub-task > Components: Rendering >Reporter: Petr Slaby > Attachments: 01_MTEXT_CS6.pdf, AxialShading.patch, > AxialShading1.patch, AxialShadingContext.java.getrgbimage, > Shading2Function2.pdf, Shading2Function2.ps, Shading2Function2text.pdf, > asy-shade.pdf, color_gradient.pdf, shading_pattern.pdf > > > AxialShadingContext#getRaster() is on top of profiler hot spots in documents > that use an axial shading. Inside it, the slowest part is calling > PDColorSpaceRGB#toRGB() and PDFunctionType3#eval() (in this order). > -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14055727#comment-14055727 ] Shaola Ren commented on PDFBOX-1915: Never mind, I just wanted to finish the work earlier. I'll work through those issues gradually. > 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, > ch14.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, example_030.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 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 sp
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14054527#comment-14054527 ] Shaola Ren commented on PDFBOX-1915: As I thought at the very beginning, I used a hashmap to store all the pixel point of an image, there is no memory consumption problem, and the speed for type 6 and 7 shading is much faster now. Using the hashmap avoids much duplicated calculation and useless list traverse. This method also avoids to write a new structure of quadtree. For other shading type, I'm sure the similar technique will be helpful too, I looked at the type 2 function and type 2 shading, there is not an obvious flaw in the code except the common flaw as type 6 and 7 shading in the getRaster() which I mostly inherited from previous code before. If you are willing to close this project earlier than the planned time Aug 19, I think I can try to finish all the improvements in 2 or 3 more weeks, the math in other types is simple and obvious. I hope you can consider this, thanks in advance. the repository https://bitbucket.org/xinshu/pdfbox.git is up to date (https://bitbucket.org/xinshu/pdfbox). > 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, example_030.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 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 p
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14052793#comment-14052793 ] Shaola Ren commented on PDFBOX-1915: Thanks, glad to hear about this message, hope there are some fun content in type 2 and 3 shading, it looks that they are more real. I'll put type 6 and 7 shading aside since now, not because getting stuck but any work will need to put time on. If you want, you can start a new thread about type 2 and 3 shading, it won't really matter. > 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, example_030.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 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 wit
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14052087#comment-14052087 ] Shaola Ren commented on PDFBOX-1915: Thanks, I'm happy to see the code in the trunk. I just looked at the example_030.pdf, especially for the page 2, the slow performance is in expectation, even if a better structure is used to store the triangles. The reason is, given an image, if you enlarge it n times in x and y directions, the rendering speed will be slowed by n^2 times as long as getRaster() is used as the current mechanism. I thought about this in a previous comment. However, I think I will focus on the structure first. > 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, example_030.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 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 fi
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14052074#comment-14052074 ] Shaola Ren commented on PDFBOX-1915: We are aware of the performance issue at the very beginning, and I talked about using a better structure to store the CoonsTriangle several times, and I mentioned sort and search before as well, the situation is the work is not done yet. For the structure to store the CoonsTriangle, I am thinking about to apply a Quadtree in the left time, before I did the work, I cannot say more about how the performance will be, and I can't guarantee anything :). However, if someone else has a really better suggestion, I am glad to take it. The answer for "break", you cannot use a break, as there may be more than one point in the unit patch mapped to the same position of the real patch, two reasons, one is digitization, the other is folding or overlap. Digitization, like a length 10 line linearly mapped to only a length 2 line (just assume they have the same unit), if it's in real space, there is no such problem that more than one point mapped to the same point, for the non-negative integer space, the problem exists. Folding, that's obvious, that's why there are priority rules for type 6 and 7 shading. It looks the macfeeU5.pdf have some overlapped patches, if a break is used, may cause some unexpected white spots, however, I didn't try. For other files, a break may not cause such a problem that's just because the issue is not triggered, you still cannot set a break in the current code. "Neighbor hit", that's possible, the same reason as above, you have to check if there are any other matched triangles for the current structure, however, I didn't have this in mind before, thanks. I'll look at the attached file. > 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, example_030.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 pdPages = document.getDocumentCatalog().getAllPages(); > int page = 0; > for (PDPage pdPag
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14051540#comment-14051540 ] Shaola Ren commented on PDFBOX-1915: just completed most of the javadoc for type 6 and 7 shading if not all, the repository https://bitbucket.org/xinshu/pdfbox.git is up to date ( https://bitbucket.org/xinshu/pdfbox). > 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 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
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14047025#comment-14047025 ] Shaola Ren commented on PDFBOX-1915: Thanks, that video is interesting. I will gradually complete the javadoc in this coming week, that's a relatively easy part, thanks for your suggestions, they are useful. > 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 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
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14044555#comment-14044555 ] Shaola Ren commented on PDFBOX-1915: refactoring, cleaning up / removing duplicate code are done and code is up to date in the usual place, except there is no detailed java doc yet. > 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 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
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14044272#comment-14044272 ] Shaola Ren commented on PDFBOX-1915: I have updated the code. OK, I will do that in the next few days or next week, it requires more carefulness for this task. > 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 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 sp
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14041910#comment-14041910 ] Shaola Ren commented on PDFBOX-1915: Thanks. A quick message about applying dividing level judging, for the lamp_cairo and macfeeU5, the rendering time can drop to around 20 s in my laptop, other test files don't have too much change, now only the shading type 7 is done, I will update code after finished shading type 6. How well the code will work on an image depends on how well the algorithm is, for the current test suit, it works. > 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 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 se
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14039614#comment-14039614 ] Shaola Ren commented on PDFBOX-1915: Thanks. Re your last comment, you are absolutely right, hahaha..., I thought you may point out this, that's because I changed the level = 4 to level = 3 in order to get a faster speed in other test cases especially for the lamp_cario and macfeeU5 to see there is nothing wrong with the code, and I know when I changed the level back to 4, everything will remain the same as before. For this time's updating, only the code related to shading type 6 had a relatively more change than shading type 7, shading type 7 is almost suitable to edit the level parameter at the beginning. > 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, > 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 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 shadi
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14038158#comment-14038158 ] Shaola Ren commented on PDFBOX-1915: For some images, the slow speed is in expectation, such as if an image is composed by hundreds of patches and each patch is composed of no more than 10 pixels, but the dividing level is still fixed to some value which is too large for such patch to cause a waste of time, another reason is that the listOfCoonsTriangle and patchList are not well structured, the current code has to traverse the lists from beginning till all the matched elements visited, this issue exists in the shading type 5 as well, although a break can be used there. update: Adjusted code suitable to set the dividing level for each patch, after I updated the code I noticed that the getLevel() in the repository should be named setLevel(). To determine the dividing level, I need to consider several sampled points' curvature in a cubic Bezier curve rather than the dimension as I thought before. I think I will focus on this issue temporarily. > 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, > 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 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,
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14032083#comment-14032083 ] Shaola Ren commented on PDFBOX-1915: And try to determine the dividing level by the real dimension of a patch rather than a fixed value. > 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, > 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, > 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 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
[jira] [Updated] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Shaola Ren updated PDFBOX-1915: --- Attachment: mcafeeU5_1.png Applied Bresenham's line algorithm, there is no weird spots for test file macfeeU5.pdf. In my opinion, next step, I will try to order listOfCoonsTriangle to optimize the time efficiency, before testing, not too sure how much will be improved. code is available in the usual place. > 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, > 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, > 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 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.
[jira] [Updated] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Shaola Ren updated PDFBOX-1915: --- Attachment: lineRasterization.jpg I roughly knew what happened when those unexpected spots came out after tracking pixels of each patch. It seems the algorithm to test whether a point on a line is not good enough, I attached a file lineRasterization.jpg, the left part shows the result of current code, the right part shows the case which I think I should use, it is called "Bresenham line algorithm", hopefully, this will solve the current problem and be done next week. > 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, > 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, > 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.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 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
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14027709#comment-14027709 ] Shaola Ren commented on PDFBOX-1915: Sorry, that condition Math.abs(a.getX() - b.getX()) < 1 should change to Math.abs(a.getX() - b.getX()) < 0.001, as in other parts I use this accuracy. However, this change won't give a big difference. I should check this bug carefully before saying anything surely. > 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, > 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, > 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, mcafeeU5.pdf, > 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 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 optimi
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14027701#comment-14027701 ] Shaola Ren commented on PDFBOX-1915: Thanks, that is helpful, it means something wrong in the precondition judgement part in the contains() method, in this branch else if (degeneracy == 2) { if (overlaps(corner[0], corner[1]) && !overlaps(corner[0], corner[2])) { return isOnLine(corner[0], corner[2], p); } else /** maybe I should separate this branch into two cases, in the current code I merged the left two cases into one**/ { return isOnLine(corner[0], corner[1], p); } } I'll check this. > 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, > 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, > 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, mcafeeU5.pdf, > 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 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/gal
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14027675#comment-14027675 ] Shaola Ren commented on PDFBOX-1915: the precondition to call the method getColorOnALine is that two points a and b are not overlapped, then I used the difference of points coordinates in x direction to scale the color, if a and b has the same x position I used the y direction. if (Math.abs(a.getX() - b.getX()) < 1), this condition deals with the a.X = b.X. the case a.Y = b.Y is included in those if ... else ... branches automatically I saw the new image you attached. I think this is caused by the method to determine whether a point is inside or outside a patch, this bug should be in the CoonsTriangle class. Even when I set the dividing level to 0, that means I only use the original control points, several white points still appear in the rendered image. I am working on it. With these various cases to take care of, the code looks ugly now. > 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, > 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, > 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, mcafeeU5.pdf, > 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 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/sh
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14027292#comment-14027292 ] Shaola Ren commented on PDFBOX-1915: The several while and black spots should be caused by unexpected calculation error, it may take time to fix this bug, I started to work on this problem. > 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, > 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, > 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, mcafeeU5.pdf, > 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 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 (
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14026147#comment-14026147 ] Shaola Ren commented on PDFBOX-1915: I thought about the macfee file more, before, my attention was attracted to the degeneracy issue, I didn't have a good understanding about what you said "Even at 300dpi, the gwg and the mcafee files don't come out well. Could it be that you're working with a too "coarse" dividing into triangles, so that only large patches look nice?". However, I am not too sure about the problem now, this method dealt with each patch separately, if each small letter in the image part of macfee is combined by several individual patches, then the method I used shouldn't cause any problem, I will think this issue more. > 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, > 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, > 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, 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 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/Go
[jira] [Updated] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Shaola Ren updated PDFBOX-1915: --- Attachment: failedTest.rar GWG060_Shading_x1a_1.png tensor4-nofunction_1.png lamp_cairo7_1.png rendering lamp_cairo.pdf, tensor4-nofunction.pdf and GWG060_Shading_x1a.pdf to image correctly as I added some code to test degeneracy, the software works slower than before, for lamp_cairo.pdf, it used 160 s to draw the picture in my laptop. failedTest.rar: still have some problem when rendering McAfee-ShadingType7.pdf, eci_altona-test-suite-v2_technical_H.pdf and XYZsweep.pdf, for those 3 test files, the bug may not be in my code, or not in the shading type 6 and 7 calculation. the code are available at https://bitbucket.org/xinshu/pdfbox.git for webview https://bitbucket.org/xinshu/pdfbox > 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, > 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, > 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, 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 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 wit
[jira] [Updated] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Shaola Ren updated PDFBOX-1915: --- Attachment: lamp_cairo7_1.png lamp_cairo7_0.png Thanks for your information and updated files. When one patch's real dimension is too large, there is indeed the "too coarse" problem in my method as I just simply define one general dividing level what I used now is 4, that means each cubic Bezier curve is divided into 1 << 4 = 16 segments, for a better version this level may be determined by the dimension of a patch but not in the current code yet and I didn't think about this issue carefully either now. There is also another problem in my code, as I divide one patch into small quadrilaterals, there are two cases that I didn't consider before, when a quadrilateral degenerates into a point or a line, which cause some parts of a shading type 7 image to be lost, you will see some parts of a graph have unexpected background color, I attached two such results lamp_cairo7_1.png and lamp_cairo7_0.png, these two graph have different dividing level. I thought another way to deal with the dividing issue, the finer the divided quadrilateral is the longer the time will be taken to calculate, when a patch is too large, I can first take it as a small patch, after calculation, I can use another method to zoom in the small patch to its real size, this can avoid the heavy calculation from control points to graph, but I still didn't think about the concrete method to accomplish this zoom in function. I believe there should be many other imperfect aspects in this method. I haven't tested the 4 flags file and gwg file yet, now I started working on the degenerated quadrilateral cases. All your information is useful. Thanks. > 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, > _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, > eci_altona-test-suite-v2_technical_H.pdf, lamp_cairo.pdf, lamp_cairo7_0.png, > lamp_cairo7_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, > 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 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 s
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14017244#comment-14017244 ] Shaola Ren commented on PDFBOX-1915: Thanks, your bug fix suggestion is right. I will follow your suggestions to modify the code. "Triangle" class is never used, I should delete it. > 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, > tensor-nofunction-RGB_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 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
[jira] [Updated] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Shaola Ren updated PDFBOX-1915: --- Attachment: tensor-nofunction-RGB_1.png test result for tensor-nonfunction-RGB.pdf, correct. The related file in JIRA for last comment is shading7.rar. code is available in bitbucket. > 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, > tensor-nofunction-RGB_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 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 s
[jira] [Updated] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ 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 <>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 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 imple
[jira] [Updated] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Shaola Ren updated PDFBOX-1915: --- Attachment: pass4FlagTest.rar passed the 4 flag test file for shading type 6 code are available at https://bitbucket.org/xinshu/pdfbox.git for web view https://bitbucket.org/xinshu/pdfbox > 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, > eci_altona-test-suite-v2_technical_H.pdf, lamp_cairo.pdf, pass4FlagTest.rar, > patchCases.jpg, patchMap.jpg, shading6ContourTest.rar, shading6Done.rar, > 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 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)
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14013432#comment-14013432 ] Shaola Ren commented on PDFBOX-1915: Thank Andreas Lehmkühler :) > 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, > eci_altona-test-suite-v2_technical_H.pdf, lamp_cairo.pdf, patchCases.jpg, > patchMap.jpg, shading6ContourTest.rar, shading6Done.rar, > 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 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)
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14013425#comment-14013425 ] Shaola Ren commented on PDFBOX-1915: For the "assign", it's fine, I was just curious about this item, and I think it's no harm to ask you this question, so I did :) For the current method I used, I don't need to consider the counterclockwise and clockwise direction, as the grid is generated automatically, all situations and priority rules are followed directly. I almost deleted all the code in CoonsPatch class and CubicBezierCurve class I wrote before May 28 and rewrite this new version by adding another class CoonsTriangle. Obviously, there is some redundant code there, I will edit this stuff last. Although, the previous version is hardly used in the current code, the previous version helped me a lot to understand the whole problem. Yes, the last strategy works, first dividing a patch to small 4-side patches, then dividing each small patch to two triangles, then create a triangle list as shading type 5, but having difference with what you coded in shading type 5, I will write a detailed document about this method later. For the "broken line" you mentioned, I looked at that, that is in my first comment in this thread, they are not broken lines, just with arrows, one arrow followed by a whole paragraph, no content missed. Yes, I am happy with this progress. > 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: 2.0.0 >Reporter: Tilman Hausherr > Labels: graphical, gsoc2014, java, math, shading > 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, > eci_altona-test-suite-v2_technical_H.pdf, lamp_cairo.pdf, patchCases.jpg, > patchMap.jpg, shading6ContourTest.rar, shading6Done.rar, > 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 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:/
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14013305#comment-14013305 ] Shaola Ren commented on PDFBOX-1915: OK, for the ECI test file, it's indeed as you said, the left lower 5 colored rectangles are not displayed. I don't think it's necessary to send another email to you about what I did in this week, all the stuff is here now, I should use this thread earlier, it's more convenient. Next week, I will start to work on shading type 7. I noticed that this project is still not assigned to anybody, I think I definitely can accomplish it now :) > 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: 2.0.0 >Reporter: Tilman Hausherr > Labels: graphical, gsoc2014, java, math, shading > 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, > eci_altona-test-suite-v2_technical_H.pdf, lamp_cairo.pdf, patchCases.jpg, > patchMap.jpg, shading6ContourTest.rar, shading6Done.rar, > 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 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
[jira] [Comment Edited] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14013212#comment-14013212 ] Shaola Ren edited comment on PDFBOX-1915 at 5/30/14 2:12 AM: - Update: I meant the technical part for shading type 6 is solved, for other details I will work on them later... Shading type 7 should be similar to shading type 6... Rendering correct shading type 6 image. This is the test result for my shading type 6 code. code are available at https://bitbucket.org/xinshu/pdfbox.git for web view https://bitbucket.org/xinshu/pdfbox related file in JIRA shading6Done.rar was (Author: xinshu): Rendering correct shading type 6 image. This is the test result for my shading type 6 code. code are available at https://bitbucket.org/xinshu/pdfbox.git for web view https://bitbucket.org/xinshu/pdfbox related file in JIRA shading6Done.rar > 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: 2.0.0 >Reporter: Tilman Hausherr > Labels: graphical, gsoc2014, java, math, shading > 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, > eci_altona-test-suite-v2_technical_H.pdf, lamp_cairo.pdf, patchCases.jpg, > patchMap.jpg, shading6ContourTest.rar, shading6Done.rar, > 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 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: > R
[jira] [Updated] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Shaola Ren updated PDFBOX-1915: --- Attachment: shading6Done.rar Rendering correct shading type 6 image. This is the test result for my shading type 6 code. code are available at https://bitbucket.org/xinshu/pdfbox.git for web view https://bitbucket.org/xinshu/pdfbox related file in JIRA shading6Done.rar > 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: 2.0.0 >Reporter: Tilman Hausherr > Labels: graphical, gsoc2014, java, math, shading > 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, > eci_altona-test-suite-v2_technical_H.pdf, lamp_cairo.pdf, patchCases.jpg, > patchMap.jpg, shading6ContourTest.rar, shading6Done.rar, > 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 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)
[jira] [Updated] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Shaola Ren updated PDFBOX-1915: --- Attachment: updateshading6ContourTest.rar extracted contour of a folded shading type 6 image > 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: 2.0.0 >Reporter: Tilman Hausherr > Labels: graphical, gsoc2014, java, math, shading > 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, > eci_altona-test-suite-v2_technical_H.pdf, lamp_cairo.pdf, patchCases.jpg, > patchMap.jpg, shading6ContourTest.rar, 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 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)
[jira] [Updated] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Shaola Ren updated PDFBOX-1915: --- Attachment: patchMap.jpg patchCases.jpg shading6ContourTest.rar > 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: 2.0.0 >Reporter: Tilman Hausherr > Labels: graphical, gsoc2014, java, math, shading > 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, > eci_altona-test-suite-v2_technical_H.pdf, lamp_cairo.pdf, patchCases.jpg, > patchMap.jpg, shading6ContourTest.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 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)
[jira] [Updated] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Shaola Ren updated PDFBOX-1915: --- Attachment: Shadingtype6week1.pdf > 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: 2.0.0 >Reporter: Tilman Hausherr > Labels: graphical, gsoc2014, java, math, shading > 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, > eci_altona-test-suite-v2_technical_H.pdf, lamp_cairo.pdf > > > 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 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)
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14011885#comment-14011885 ] Shaola Ren commented on PDFBOX-1915: an even older stuff the reading data part is almost done the code are available at https://bitbucket.org/xinshu/pdfbox.git for webview https://bitbucket.org/xinshu/pdfbox This is stuff edited from the emails from me and Tilman, I am sorry that I didn't post my questions on Jira earlier, hopefully these emails don't have any thing that is not suitable to be published publicly, if there are such issues, Tilman Please, Feel free to delete or edit them. I am sorry for this unconvenience. related file is Shadingtype6week1.pdf May 23 >From Shaola to Tilman Hello Tilman, I modified the shading package, and the code are available at https://bitbucket.org/xinshu/pdfbox.git, midway done, may have bugs. However, It’s better to summarize the progress made in this week and talk to you to get some feedback. Any suggestion is appreciated, take you time. I encountered some questions which I put in this powerpoint(attached) and highlighted by blue color. If these questions are too vague, you don’t need to give an explicit answer. Thanks! >From Tilman to Shaola Quick answer - to use LOG.debug() you must set debug level. This is done in the file "log4j.properties" in the default package of your application. Alternatively, use LOG.info() and it should work immediately (with the command line utility) Here's a sample log4j file with debug level enabled: log4j.rootLogger=DEBUG, A1 #log4j.rootLogger=INFO, A1 # A1 is set to be a ConsoleAppender. log4j.appender.A1=org.apache.log4j.ConsoleAppender # A1 uses PatternLayout. log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%d{dd.MM. HH:mm:ss.SSS} %-5p [%t] %C:%L - %m%n System.out.println() is the quick way, but you should get used to use "apache log4j". Download it at https://logging.apache.org/log4j/1.2/ and attach it to your calling application. Yes, it takes that long to build. You could probably write a script to copy the class file that is created while editing and insert it to an existing jar file. I assume you could also skip the tests. I just tested this :-) https://maven.apache.org/surefire/maven-surefire-plugin/examples/skipping-test.html just add -DskipTests Hello Shaola, /ShadingType 6 /ColorSpace/DeviceRGB /Decode[-16384 16384 -16384 16384 0 1 0 1 0 1] /BitsPerCoordinate 24 /BitsPerComponent 16 /BitsPerFlag 8 BitsPerCoordinate = 24, it means that the max value in the stream for a coordinate is 0xFF = 16777215. This is then mapped to the target which has an interval [-16384..16384] with "interpolate". The values you get must then be "transformed" into the physical coordinates, which is done in GouraudShadingContext.transformVertices(). You can probably reuse this. At first, just make yourself a copy; later in the project, it should possibly be merged so that no code exists twice. https://en.wikipedia.org/wiki/Don%27t_repeat_yourself Re "transform", this is two things: 1) PDF related transformations, i.e. mentioned in the PDF 2) java graphics transform: depends on the size of the image. Usually this is a scale, 4.16 for 300dpi. I don't see that you did the transform, which may explain why you get such weird coordinates... and yes, after the transforms, you get physical coords. Look at Gouraud shading, the transform is done at the beginning only, i.e. only once. In getRaster(), you then work with "real, screen" coordinates. I don't think it is useful to generate the points separately, as they are painted only once. The raster in which the other shading classes are writing into is a "Table", somehow. Some people render at 300dpi. An A4 page is about 2500 x 3500 pixels. Re getraster(): yes, getraster only paints a small section. It is called again and again and again. X and Y are physical pixels. I strongly recommend to first "get something simple that works". Even if slow. From there, you can try to make changes, and if these go wrong, you can always go back to the "simple" solution. Hint: output the "raw" coordinates and the interval boundaries in hex. This is done with System.out.println (String.format("%x", val)). This gives you a better idea of the relationships between the numbers. Minor thing: getParamSpaceColor(int i, int j) are these coordinates? If yes, please name them x and y. Same for getPatchCoordinates. I hope I answered most, if not all. Good luck! >From Shaola to Tilman 2) java graphics transform: depends on the size of the image. Usually this is a scale, 4.16 for 300dpi. I don't see that you did the transform, which may explain why you get such weird coordinates... and yes, after the transforms, you get physical coords. I will check this
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14011877#comment-14011877 ] Shaola Ren commented on PDFBOX-1915: those are old stuffs, hopefully there are useful for someone got correct contour of shading type 6 image the code are available at https://bitbucket.org/xinshu/pdfbox.git for webview https://bitbucket.org/xinshu/pdfbox related files are in file shading6ContourTest.rar This is stuff edited from the emails from me and Tilman, I am sorry that I didn't post my questions on Jira earlier, hopefully these emails don't have any thing that is not suitable to be published publicly, if there are such issues, Tilman Please, Feel free to delete or edit them. I am sorry for this unconvenience. >From Shaola to Tilman Hi Tilman, Now, I can get correct shape of an image of shading type 6, this is the item 1 of my last email. The result of the two test files are attached, you will see each patch has a solid color, that's because I still didn't work on color calculation, I just gave each point inside a patch the same color. Generally, to accomplish this task(the shape), I need to consider 3 cases which I drew in patchCase.jpg labeled with 1, 2, 3. For case 1 and 2, each of them can have another 3 subcases which I labeled them with "1,2 could be" at the bottom of patchCase.jpg. The two test files only involve cases 1 and 2, the 3rd case is more complex, I need to split one patch into 2 quasi-triangle patch. Now the code does not work for case 3. The color of a patch is not calculated yet, which is the item 2 of my last email. The progress is a little bit slower than I thought, there are many unexpected issues. I think I need to follow plan B in my proposal. >From Tilman to Shaola Hi Shaola, Don't panic. IMHO you're doing pretty good. Don't forget that you just started a week ago. >From Tilman to Shaola Hello Shaola, Look what I found: https://www.google.ca/patents/US6552725 HOWEVER the bad news is that most likely you can't use that solution because it is patented. Apache is a US based corporation and software patents are valid there. I uploaded more examples in JIRA. Only one of them deals with coons patches. Tilman >From Shaola to Tilman Hello Tilman, Thanks, the attachment is the contour results of several test files, for coons26.pdf, the result is weird. The two new test cases have true hasFunction parameter, they helped me to adjust my reading method to deal with this case. I noticed that in the GouraudShadingContext.java, this issue in the method readVertex is not taken into account, although in the getRaster(), this case is considered, but I think it will generate a null pointer exception when it reads an image of shading type 4 or 5 with a true hasFunction parameter, I didn't test this yet. For other issues, with time I think they should be worked out in a way. >From Tilman to Shaola Hi Shaola, I believe this is a misunderstanding because the arrangement of the values is different for type 6 than type 4/5. See this part of the spec for type 5 on page 324: If this entry is present, the color data for each vertex must be specified by a single parametric variable rather than by n separate color components. ... The data stream provides a sequence of Bézier control points and color values that define the shape and colors of each patch. All of a patch’s control points are given first, followed by the color values for its corners. Note that this differs from a triangle mesh (shading types 4 and 5), in which the coordinates and color of each vertex are given together. So function = true means that there will be one value. You can handle this as if you had a grayscale image, which also means that there is 1 color value. Re sequence: you first interpolate to get the value of a point, then you feed that value to the function, which will return a Color array. That one you then convert to RGB as in the existing code. In other words, you don't have to bother much about the function thing. Attached: two examples of coons patches without a function. One RGB and one gray. Hi Shaola, No, the amount of color values goes like this, if I've understood it correctly: hasFunction = true ==> 1 value hasFunction = false: depends of colorspace gray => 1 value rgb => 3 values cmyk => 4 values other color spaces... who knows. Attached you see a coons patch with two color values ("duotone", this is a weird mix of red and black that I took from a ps file of Prof. Bill Casselman) and one with 4 (cmyk). However I suspect that you did indeed find a bug in my software, i.e. numberofcolorcomponents should be 1 if function. Oops. I will research this now that I'm getting better in postscript and create a Gouraud shading with function. Tilman >From Shaola to Tilman, Hello Tilma
[jira] [Commented] (PDFBOX-1915) Implement shading with Coons and tensor-product patch meshes
[ https://issues.apache.org/jira/browse/PDFBOX-1915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14011876#comment-14011876 ] Shaola Ren commented on PDFBOX-1915: A strategy to decide patch coordinates and color the code are available at https://bitbucket.org/xinshu/pdfbox.git for web view https://bitbucket.org/xinshu/pdfbox This is stuff edited from the emails from me and Tilman, I am sorry that I didn't post my questions on Jira earlier, hopefully these emails don't have any thing that is not suitable to be published publicly, if there are such issues, Tilman, Please, Feel free to delete or edit them. I am sorry for this unconvenience. Hello Shaola, I can't really decide about the strategy because it involves math and this is my weak point. What I have understood so far is: - you have problem using the strategy mentioned in the project description, i.e. deciding color and position (inside/outside) in getRaster() based on the current point. Because you can easily draw a coons patch by having an image to draw into, but not the opposite way, i.e. having a point and then decide. - you can possibly do it if you are using a helper table, but that can cost memory - another strategy is to divide the patch into tiny triangles (which will create something not-so-perfect like I e-mailed you) As I said, I favor a strategy that gives results first. One could also use a misc strategy, i.e. one for the unfolded patches and one for the folded ones. You can also ask math questions on http://math.stackexchange.com, as long as these are specific questions on small problems, and that you credit the answer in your code. Some general stuff: - did you read my "community bonding period" message in the dev list? I realize that we're not respecting the rules, i.e. this technical talk should be in the JIRA issue. The best would be that you write a summary and post it there, or open a comment with copy&paste with each of the mails, and also attach that drawing, and the patch outlines. I think this is about 3-5 mails only. You don't have to do it immediately, but it should be done by the end of the week. - the more general talk about pdfbox can be in the dev list. - please post the bitbucket URL in the JIRA issue - The advantage is that other developers can also give you good advice, not just me - what you're working on is kindof the "top of the pyramid" for shadings. Several other open source programs support only shadings 1-3, same for several closed source programs. If you succeed, the Google summer of code is a great addition to your CV! Tilman Am 28.05.2014 16:35, schrieb 任少辣: > Hello Tilman, > > I thought it more, may be first just focus on getting an image close to the > original image, I mean the expected image will be less smooth than the original one. > > I can avoid to generate all the points information by creating a triangle > list similar to shading type 5 after step 2, then the accomplishment is reduced to triangle meshes. The cubic Bezier curve information and bilinear interpolation of color are reserved as well, as they are used in step 1 and 2. For this updated method, I have more confidence if you can bear the error I mean the image will be less smooth as I need to approximate a curve segment to a line segment, with a trade off of speed, the error can be adjusted by changing the density of the grid. > > Sorry for the frequent changes, but we should admit that just learning the > information in the pdf document is not sufficient, at least I think this is the truth. > > Best, > Shaola > > Sorry, there is a calculation typo in the last email if you received, 20 x 9 > x 10^4 bytes ~ 2 MB, not 20 x 9 x 10^2 bytes ~ 2 MB > > Maybe it is worth to try my original method, with this method, I think at > least it may give a complete result for the test files I already have. > > The details of the method is as following, it generates every point in a > patch, now every point in a patch is created by search. > > A unit patch mapped to a real patch, the real patch can be described by the > assistant variable u and v in the unit patch. > > 1. dividing the unit patch into a m x n grid, then using cubic bezier curve, > I can map this grid to the real patch, during this process, the coordinate and color of cross point can be determined directly (cubic bezier curve and bilinear interpolation). > > 2. in the mapped patch, the curve which forms the mapped grid will be taken > as a composition of many line segments, then the whole mapped patch is formed by many small quadrilaterals, splitting each quadrilateral into two triangle as I showed in the graph to solve the potential folding issue, now for each triangle, the color and position of each corner are already calculated, for the points inside a triangle, the color is calculated by barycentric