/* */ public static void fillBackground(WritableRaster raster, Rectangle rect, double[] backgroundValues)
/* */ {
/* 1045 */ rect = rect.intersection(raster.getBounds());
/* 1046 */ int numBands = raster.getSampleModel().getNumBands();
/* 1047 */ SampleModel sm = raster.getSampleModel();
/* 1048 */ PixelAccessor accessor = new PixelAccessor(sm, null);
/* */
/* 1050 */ if (isBinary(sm))
/* */ {
/* 1052 */ byte value = (byte)((int)backgroundValues[0] & 0x1);
/* 1053 */ if (value == 0)
/* 1054 */ return;
/* 1055 */ int rectX = rect.x;
/* 1056 */ int rectY = rect.y;
/* 1057 */ int rectWidth = rect.width;
/* 1058 */ int rectHeight = rect.height;
/* */
/* 1060 */ int dx = rectX - raster.getSampleModelTranslateX();
/* 1061 */ int dy = rectY - raster.getSampleModelTranslateY();
/* */
/* 1063 */ DataBuffer dataBuffer = raster.getDataBuffer();
/* 1064 */ MultiPixelPackedSampleModel mpp = (MultiPixelPackedSampleModel)sm;
/* 1065 */ int lineStride = mpp.getScanlineStride();
/* 1066 */ int eltOffset = dataBuffer.getOffset() + mpp.getOffset(dx, dy);
/* 1067 */ int bitOffset = mpp.getBitOffset(dx);
/* */
/* 1069 */ switch (sm.getDataType())
/* */ {
/* */ case 0:
/* 1072 */ byte[] data = ((DataBufferByte)dataBuffer).getData();
/* 1073 */ int bits = bitOffset & 0x7;
/* 1074 */ int otherBits = bits == 0 ? 0 : 8 - bits;
/* */
/* 1076 */ byte mask = (byte)(255 >> bits);
/* 1077 */ int lineLength = (rectWidth - otherBits) / 8;
/* 1078 */ int bits1 = rectWidth - otherBits & 0x7;
/* 1079 */ byte mask1 = (byte)(255 << 8 - bits1);
/* */
/* 1081 */ for (int y = 0; y < rectHeight; y++) {
/* 1082 */ int start = eltOffset;
/* 1083 */ if (bits != 0)
/* 1084 */ data[(start++)] = mask;
/* 1085 */ int end = start + lineLength;
/* 1086 */ while (start < end)
/* 1087 */ data[(start++)] = -1;
/* 1088 */ if (bits1 != 0)
/* 1089 */ data[(start++)] = mask1;
/* 1090 */ eltOffset += lineStride;
/* */ }
/* 1092 */ break;
/* */ case 1:
/* */ case 2:
/* 1097 */ short[] data = ((DataBufferShort)dataBuffer).getData();
/* 1098 */ int bits = bitOffset & 0xF;
/* 1099 */ int otherBits = bits == 0 ? 0 : 16 - bits;
/* */
/* 1101 */ short mask = (short)(65535 >> bits);
/* 1102 */ int lineLength = (rectWidth - otherBits) / 16;
/* 1103 */ int bits1 = rectWidth - otherBits & 0xF;
/* 1104 */ short mask1 = (short)(65535 << 16 - bits1);
/* */
/* 1106 */ for (int y = 0; y < rectHeight; y++) {
/* 1107 */ int start = eltOffset;
/* 1108 */ if (bits != 0)
/* 1109 */ data[(start++)] = mask;
/* 1110 */ int end = start + lineLength;
/* 1111 */ while (start < end)
/* 1112 */ data[(start++)] = -1;
/* 1113 */ if (bits1 != 0)
/* 1114 */ data[(start++)] = mask1;
/* 1115 */ eltOffset += lineStride;
/* */ }
/* 1117 */ break;
/* */ case 3:
/* 1121 */ int[] data = ((DataBufferInt)dataBuffer).getData();
/* 1122 */ int bits = bitOffset & 0x1F;
/* 1123 */ int otherBits = bits == 0 ? 0 : 32 - bits;
/* */
/* 1125 */ short mask = (short)(-1 >> bits);
/* 1126 */ int lineLength = (rectWidth - otherBits) / 32;
/* 1127 */ int bits1 = rectWidth - otherBits & 0x1F;
/* 1128 */ short mask1 = (short)(-1 << 32 - bits1);
/* */
/* 1130 */ for (int y = 0; y < rectHeight; y++) {
/* 1131 */ int start = eltOffset;
/* 1132 */ if (bits != 0)
/* 1133 */ data[(start++)] = mask;
/* 1134 */ int end = start + lineLength;
/* 1135 */ while (start < end)
/* 1136 */ data[(start++)] = -1;
/* 1137 */ if (bits1 != 0)
/* 1138 */ data[(start++)] = mask1;
/* 1139 */ eltOffset += lineStride;
/* */ }
/* 1141 */ break;
/* */ }
/* */ }
/* */ else
/* */ {
/* 1146 */ int srcSampleType = accessor.sampleType == -1 ? 0 : accessor.sampleType;
/* */
/* 1148 */ UnpackedImageData uid = accessor.getPixels(raster, rect, srcSampleType, false);
/* */
/* 1150 */ rect = uid.rect;
/* 1151 */ int lineStride = uid.lineStride;
/* 1152 */ int pixelStride = uid.pixelStride;
/* */