Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 327ba75

Browse files
author
tvtreeck
committed
added missing shading files
1 parent 3f6afc6 commit 327ba75

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+4986
-281
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>org.jpedal</groupId>
77
<artifactId>jpedal_lgpl</artifactId>
8-
<version>4.92-p7</version>
8+
<version>4.92-p8</version>
99
<description>Patched jPedal based on the last official jpedal version 4.92</description>
1010

1111
<build>
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/*
2+
* ===========================================
3+
* Java Pdf Extraction Decoding Access Library
4+
* ===========================================
5+
*
6+
* Project Info: http://www.idrsolutions.com
7+
*
8+
* List of all example and a link to zip at http://www.idrsolutions.com/java-code-examples-for-pdf-files/
9+
*
10+
* (C) Copyright 1997-2014, IDRsolutions and Contributors.
11+
*
12+
* This file is part of JPedal
13+
*
14+
This library is free software; you can redistribute it and/or
15+
modify it under the terms of the GNU Lesser General Public
16+
License as published by the Free Software Foundation; either
17+
version 2.1 of the License, or (at your option) any later version.
18+
19+
This library is distributed in the hope that it will be useful,
20+
but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22+
Lesser General Public License for more details.
23+
24+
You should have received a copy of the GNU Lesser General Public
25+
License along with this library; if not, write to the Free Software
26+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27+
28+
29+
*
30+
*
31+
* ---------------
32+
* BMContext.java
33+
* ---------------
34+
*/
35+
package com.idrsolutions.pdf.color.blends;
36+
37+
import java.awt.CompositeContext;
38+
import java.awt.image.DataBuffer;
39+
import java.awt.image.Raster;
40+
import java.awt.image.WritableRaster;
41+
42+
/**
43+
*
44+
*/
45+
abstract class BMContext implements CompositeContext {
46+
47+
float alpha;
48+
49+
BMContext(final float alpha) {
50+
this.alpha=alpha;
51+
}
52+
53+
@Override
54+
public void dispose() {
55+
56+
}
57+
58+
@Override
59+
//based on code showing how to do this
60+
//http://www.curious-creature.org/2006/09/20/new-blendings-modes-for-java2d/
61+
public void compose(final Raster src, final Raster dstIn, final WritableRaster dstOut) {
62+
63+
if (src.getSampleModel().getDataType() != DataBuffer.TYPE_INT ||
64+
dstIn.getSampleModel().getDataType() != DataBuffer.TYPE_INT ||
65+
dstOut.getSampleModel().getDataType() != DataBuffer.TYPE_INT) {
66+
throw new IllegalStateException(
67+
"Source and destination must store pixels as INT.");
68+
}
69+
70+
final int width = Math.min(src.getWidth(), dstIn.getWidth());
71+
final int height = Math.min(src.getHeight(), dstIn.getHeight());
72+
73+
final int[] srcPixel = new int[4];
74+
final int[] dstPixel = new int[4];
75+
final int[] srcPixels = new int[width];
76+
final int[] dstPixels = new int[width];
77+
78+
for (int y = 0; y < height; y++) {
79+
src.getDataElements(0, y, width, 1, srcPixels);
80+
dstIn.getDataElements(0, y, width, 1, dstPixels);
81+
for (int x = 0; x < width; x++) {
82+
// pixels are stored as INT_ARGB
83+
// our arrays are [R, G, B, A]
84+
int pixel = srcPixels[x];
85+
srcPixel[0] = (pixel >> 16) & 0xFF;
86+
srcPixel[1] = (pixel >> 8) & 0xFF;
87+
srcPixel[2] = (pixel ) & 0xFF;
88+
srcPixel[3] = (pixel >> 24) & 0xFF;
89+
90+
pixel = dstPixels[x];
91+
dstPixel[0] = (pixel >> 16) & 0xFF;
92+
dstPixel[1] = (pixel >> 8) & 0xFF;
93+
dstPixel[2] = (pixel ) & 0xFF;
94+
dstPixel[3] = (pixel >> 24) & 0xFF;
95+
96+
final int[] result =blend(srcPixel, dstPixel);
97+
alpha = result[3]/255f;
98+
99+
// mixes the result with the opacity
100+
dstPixels[x] = ((int) (dstPixel[3] + (result[3] - dstPixel[3]) * alpha) & 0xFF) << 24 |
101+
((int) (dstPixel[0] + (result[0] - dstPixel[0]) * alpha) & 0xFF) << 16 |
102+
((int) (dstPixel[1] + (result[1] - dstPixel[1]) * alpha) & 0xFF) << 8 |
103+
(int) (dstPixel[2] + (result[2] - dstPixel[2]) * alpha) & 0xFF;
104+
}
105+
dstOut.setDataElements(0, y, width, 1, dstPixels);
106+
}
107+
}
108+
109+
int[] blend(final int[] srcPixel, final int[] dstPixel){
110+
111+
if(1==1) {
112+
throw new UnsupportedOperationException("Not supported yet.");
113+
}
114+
115+
return new int[4];
116+
}
117+
118+
}
119+
120+
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* ===========================================
3+
* Java Pdf Extraction Decoding Access Library
4+
* ===========================================
5+
*
6+
* Project Info: http://www.idrsolutions.com
7+
*
8+
* List of all example and a link to zip at http://www.idrsolutions.com/java-code-examples-for-pdf-files/
9+
*
10+
* (C) Copyright 1997-2014, IDRsolutions and Contributors.
11+
*
12+
* This file is part of JPedal
13+
*
14+
This library is free software; you can redistribute it and/or
15+
modify it under the terms of the GNU Lesser General Public
16+
License as published by the Free Software Foundation; either
17+
version 2.1 of the License, or (at your option) any later version.
18+
19+
This library is distributed in the hope that it will be useful,
20+
but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22+
Lesser General Public License for more details.
23+
24+
You should have received a copy of the GNU Lesser General Public
25+
License along with this library; if not, write to the Free Software
26+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27+
28+
29+
*
30+
*
31+
* ---------------
32+
* BlendMode.java
33+
* ---------------
34+
*/
35+
package com.idrsolutions.pdf.color.blends;
36+
37+
import java.awt.Composite;
38+
import java.awt.CompositeContext;
39+
import java.awt.RenderingHints;
40+
import java.awt.image.ColorModel;
41+
42+
/**
43+
*
44+
*/
45+
public class BlendMode implements Composite{
46+
47+
int blendMode;
48+
49+
float alpha;
50+
51+
public BlendMode(final int blendMode, final float alpha) {
52+
this.blendMode=blendMode;
53+
this.alpha=alpha;
54+
}
55+
56+
@Override
57+
public CompositeContext createContext(final ColorModel srcColorModel, final ColorModel dstColorModel, final RenderingHints hints) {
58+
59+
return ContextFactory.getBlendContext(blendMode,alpha);
60+
}
61+
62+
}
63+
64+
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* ===========================================
3+
* Java Pdf Extraction Decoding Access Library
4+
* ===========================================
5+
*
6+
* Project Info: http://www.idrsolutions.com
7+
*
8+
* List of all example and a link to zip at http://www.idrsolutions.com/java-code-examples-for-pdf-files/
9+
*
10+
* (C) Copyright 1997-2013, IDRsolutions and Contributors.
11+
*
12+
* This file is part of JPedal
13+
*
14+
This library is free software; you can redistribute it and/or
15+
modify it under the terms of the GNU Lesser General Public
16+
License as published by the Free Software Foundation; either
17+
version 2.1 of the License, or (at your option) any later version.
18+
19+
This library is distributed in the hope that it will be useful,
20+
but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22+
Lesser General Public License for more details.
23+
24+
You should have received a copy of the GNU Lesser General Public
25+
License along with this library; if not, write to the Free Software
26+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27+
28+
29+
*
30+
*
31+
* ---------------
32+
* ContextFactory.java
33+
* ---------------
34+
*/
35+
package com.idrsolutions.pdf.color.blends;
36+
37+
import java.awt.CompositeContext;
38+
import org.jpedal.objects.raw.PdfDictionary;
39+
40+
/**
41+
*
42+
*/
43+
class ContextFactory {
44+
45+
static CompositeContext getBlendContext(final int blendMode, final float alpha) {
46+
47+
CompositeContext context;
48+
49+
switch(blendMode){
50+
51+
case PdfDictionary.Multiply:
52+
53+
context=new Multiply(alpha);
54+
break;
55+
56+
case PdfDictionary.Normal:
57+
//should never be called but here for completeness
58+
59+
case PdfDictionary.Overlay:
60+
61+
context=new Overlay(alpha);
62+
break;
63+
64+
case PdfDictionary.Screen:
65+
context = new Screen(alpha);
66+
break;
67+
68+
case PdfDictionary.HardLight:
69+
context = new HardLight(alpha);
70+
break;
71+
72+
case PdfDictionary.Darken:
73+
context = new Darken(alpha);
74+
break;
75+
default:
76+
77+
context=new UnimplementedContext(alpha);
78+
break;
79+
}
80+
81+
return context;
82+
}
83+
84+
}
85+
86+
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* ===========================================
3+
* Java Pdf Extraction Decoding Access Library
4+
* ===========================================
5+
*
6+
* Project Info: http://www.idrsolutions.com
7+
*
8+
* List of all example and a link to zip at http://www.idrsolutions.com/java-code-examples-for-pdf-files/
9+
*
10+
* (C) Copyright 1997-2014, IDRsolutions and Contributors.
11+
*
12+
* This file is part of JPedal
13+
*
14+
This library is free software; you can redistribute it and/or
15+
modify it under the terms of the GNU Lesser General Public
16+
License as published by the Free Software Foundation; either
17+
version 2.1 of the License, or (at your option) any later version.
18+
19+
This library is distributed in the hope that it will be useful,
20+
but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22+
Lesser General Public License for more details.
23+
24+
You should have received a copy of the GNU Lesser General Public
25+
License along with this library; if not, write to the Free Software
26+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27+
28+
29+
*
30+
*
31+
* ---------------
32+
* Darken.java
33+
* ---------------
34+
*/
35+
package com.idrsolutions.pdf.color.blends;
36+
37+
/**
38+
*
39+
*/
40+
public class Darken extends BMContext {
41+
42+
public Darken(final float alpha) {
43+
super(alpha);
44+
}
45+
46+
@Override
47+
int[] blend(final int[] src, final int[] dst){
48+
49+
int[] ndst = new int[4];
50+
51+
if((src[0]==0 && src[1]==0 && src[2]==0 && src[3]==0)){
52+
ndst = dst;
53+
dst[3]=255;
54+
55+
}else{
56+
for(int a=0;a<src.length;a++){
57+
if(dst[a]<src[a]) {
58+
ndst[a] = dst[a];
59+
}else{
60+
ndst[a] = src[a];
61+
}
62+
}
63+
}
64+
ndst[3]=255;
65+
66+
return ndst;
67+
}
68+
69+
}
70+
71+

0 commit comments

Comments
 (0)