Type1ShadingContext.java (pdfbox-2.0.23-src) | : | Type1ShadingContext.java (pdfbox-2.0.24-src) | ||
---|---|---|---|---|
skipping to change at line 104 | skipping to change at line 104 | |||
public ColorModel getColorModel() | public ColorModel getColorModel() | |||
{ | { | |||
return super.getColorModel(); | return super.getColorModel(); | |||
} | } | |||
@Override | @Override | |||
public Raster getRaster(int x, int y, int w, int h) | public Raster getRaster(int x, int y, int w, int h) | |||
{ | { | |||
WritableRaster raster = getColorModel().createCompatibleWritableRaster(w , h); | WritableRaster raster = getColorModel().createCompatibleWritableRaster(w , h); | |||
int[] data = new int[w * h * 4]; | int[] data = new int[w * h * 4]; | |||
float[] values = new float[2]; | ||||
for (int j = 0; j < h; j++) | for (int j = 0; j < h; j++) | |||
{ | { | |||
for (int i = 0; i < w; i++) | for (int i = 0; i < w; i++) | |||
{ | { | |||
int index = (j * w + i) * 4; | int index = (j * w + i) * 4; | |||
boolean useBackground = false; | boolean useBackground = false; | |||
float[] values = new float[] { x + i, y + j }; | values[0] = x + i; | |||
values[1] = y + j; | ||||
rat.transform(values, 0, values, 0, 1); | rat.transform(values, 0, values, 0, 1); | |||
if (values[0] < domain[0] || values[0] > domain[1] || | if (values[0] < domain[0] || values[0] > domain[1] || | |||
values[1] < domain[2] || values[1] > domain[3]) | values[1] < domain[2] || values[1] > domain[3]) | |||
{ | { | |||
if (getBackground() == null) | if (getBackground() == null) | |||
{ | { | |||
continue; | continue; | |||
} | } | |||
useBackground = true; | useBackground = true; | |||
} | } | |||
// evaluate function | // evaluate function | |||
float[] tmpValues; // "values" can't be reused due to different length | ||||
if (useBackground) | if (useBackground) | |||
{ | { | |||
values = getBackground(); | tmpValues = getBackground(); | |||
} | } | |||
else | else | |||
{ | { | |||
try | try | |||
{ | { | |||
values = type1ShadingType.evalFunction(values); | tmpValues = type1ShadingType.evalFunction(values); | |||
} | } | |||
catch (IOException e) | catch (IOException e) | |||
{ | { | |||
LOG.error("error while processing a function", e); | LOG.error("error while processing a function", e); | |||
continue; | ||||
} | } | |||
} | } | |||
// convert color values from shading color space to RGB | // convert color values from shading color space to RGB | |||
PDColorSpace shadingColorSpace = getShadingColorSpace(); | PDColorSpace shadingColorSpace = getShadingColorSpace(); | |||
if (shadingColorSpace != null) | if (shadingColorSpace != null) | |||
{ | { | |||
try | try | |||
{ | { | |||
values = shadingColorSpace.toRGB(values); | tmpValues = shadingColorSpace.toRGB(tmpValues); | |||
} | } | |||
catch (IOException e) | catch (IOException e) | |||
{ | { | |||
LOG.error("error processing color space", e); | LOG.error("error processing color space", e); | |||
continue; | ||||
} | } | |||
} | } | |||
data[index] = (int) (values[0] * 255); | data[index] = (int) (tmpValues[0] * 255); | |||
data[index + 1] = (int) (values[1] * 255); | data[index + 1] = (int) (tmpValues[1] * 255); | |||
data[index + 2] = (int) (values[2] * 255); | data[index + 2] = (int) (tmpValues[2] * 255); | |||
data[index + 3] = 255; | data[index + 3] = 255; | |||
} | } | |||
} | } | |||
raster.setPixels(0, 0, w, h, data); | raster.setPixels(0, 0, w, h, data); | |||
return raster; | return raster; | |||
} | } | |||
public float[] getDomain() | public float[] getDomain() | |||
{ | { | |||
return domain; | return domain; | |||
End of changes. 9 change blocks. | ||||
7 lines changed or deleted | 12 lines changed or added |