Java Code Examples for java.awt.image.IndexColorModel#getPixelSize()
The following examples show how to use
java.awt.image.IndexColorModel#getPixelSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColorMap.java From jtk with Apache License 2.0 | 6 votes |
/** * Returns an index color model with specified opacity (alpha). * @param icm an index color model from which to copy RGBs. * @param alpha opacity in the range [0.0,1.0]. * @return the index color model with alpha. */ public static IndexColorModel setAlpha(IndexColorModel icm, double alpha) { int bits = icm.getPixelSize(); int size = icm.getMapSize(); byte[] r = new byte[size]; byte[] g = new byte[size]; byte[] b = new byte[size]; byte[] a = new byte[size]; icm.getReds(r); icm.getGreens(g); icm.getBlues(b); byte ia = (byte)(255.0*alpha+0.5); for (int i=0; i<size; ++i) a[i] = ia; return new IndexColorModel(bits,size,r,g,b,a); }
Example 2
Source File: ColorMap.java From jtk with Apache License 2.0 | 6 votes |
/** * Returns an index color model with specified opacities (alphas). * @param icm an index color model from which to copy RGBs. * @param alpha array of opacities in the range [0.0,1.0]. * @return the index color model with alphas. */ public static IndexColorModel setAlpha(IndexColorModel icm, float[] alpha) { int bits = icm.getPixelSize(); int size = icm.getMapSize(); byte[] r = new byte[size]; byte[] g = new byte[size]; byte[] b = new byte[size]; byte[] a = new byte[size]; icm.getReds(r); icm.getGreens(g); icm.getBlues(b); int n = min(size,alpha.length); for (int i=0; i<n; ++i) a[i] = (byte)(255.0f*alpha[i]+0.5f); return new IndexColorModel(bits,size,r,g,b,a); }
Example 3
Source File: HeadlessIndexColorModel.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String args[]) { IndexColorModel cm = new IndexColorModel(8, 1, new byte[]{(byte) 128}, new byte[]{(byte) 128}, new byte[]{(byte) 128}); cm.getTransparency(); cm.getComponentSize(); cm.isAlphaPremultiplied(); cm.hasAlpha(); cm.isAlphaPremultiplied(); cm.getTransferType(); cm.getPixelSize(); cm.getComponentSize(); cm.getNumComponents(); cm.getNumColorComponents(); cm.getRed(20); cm.getGreen(20); cm.getBlue(20); cm.getAlpha(20); cm.getRGB(20); cm.isAlphaPremultiplied(); }
Example 4
Source File: WPrinterJob.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
protected void drawDIBImage(byte[] image, float destX, float destY, float destWidth, float destHeight, float srcX, float srcY, float srcWidth, float srcHeight, int sampleBitsPerPixel, IndexColorModel icm) { int bitCount = 24; byte[] bmiColors = null; if (icm != null) { bitCount = sampleBitsPerPixel; bmiColors = new byte[(1<<icm.getPixelSize())*4]; for (int i=0;i<icm.getMapSize(); i++) { bmiColors[i*4+0]=(byte)(icm.getBlue(i)&0xff); bmiColors[i*4+1]=(byte)(icm.getGreen(i)&0xff); bmiColors[i*4+2]=(byte)(icm.getRed(i)&0xff); } } drawDIBImage(getPrintDC(), image, destX, destY, destWidth, destHeight, srcX, srcY, srcWidth, srcHeight, bitCount, bmiColors); }
Example 5
Source File: WPrinterJob.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
protected void drawDIBImage(byte[] image, float destX, float destY, float destWidth, float destHeight, float srcX, float srcY, float srcWidth, float srcHeight, int sampleBitsPerPixel, IndexColorModel icm) { int bitCount = 24; byte[] bmiColors = null; if (icm != null) { bitCount = sampleBitsPerPixel; bmiColors = new byte[(1<<icm.getPixelSize())*4]; for (int i=0;i<icm.getMapSize(); i++) { bmiColors[i*4+0]=(byte)(icm.getBlue(i)&0xff); bmiColors[i*4+1]=(byte)(icm.getGreen(i)&0xff); bmiColors[i*4+2]=(byte)(icm.getRed(i)&0xff); } } drawDIBImage(getPrintDC(), image, destX, destY, destWidth, destHeight, srcX, srcY, srcWidth, srcHeight, bitCount, bmiColors); }
Example 6
Source File: WPrinterJob.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
protected void drawDIBImage(byte[] image, float destX, float destY, float destWidth, float destHeight, float srcX, float srcY, float srcWidth, float srcHeight, int sampleBitsPerPixel, IndexColorModel icm) { int bitCount = 24; byte[] bmiColors = null; if (icm != null) { bitCount = sampleBitsPerPixel; bmiColors = new byte[(1<<icm.getPixelSize())*4]; for (int i=0;i<icm.getMapSize(); i++) { bmiColors[i*4+0]=(byte)(icm.getBlue(i)&0xff); bmiColors[i*4+1]=(byte)(icm.getGreen(i)&0xff); bmiColors[i*4+2]=(byte)(icm.getRed(i)&0xff); } } drawDIBImage(getPrintDC(), image, destX, destY, destWidth, destHeight, srcX, srcY, srcWidth, srcHeight, bitCount, bmiColors); }
Example 7
Source File: WPrinterJob.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
protected void drawDIBImage(byte[] image, float destX, float destY, float destWidth, float destHeight, float srcX, float srcY, float srcWidth, float srcHeight, int sampleBitsPerPixel, IndexColorModel icm) { int bitCount = 24; byte[] bmiColors = null; if (icm != null) { bitCount = sampleBitsPerPixel; bmiColors = new byte[(1<<icm.getPixelSize())*4]; for (int i=0;i<icm.getMapSize(); i++) { bmiColors[i*4+0]=(byte)(icm.getBlue(i)&0xff); bmiColors[i*4+1]=(byte)(icm.getGreen(i)&0xff); bmiColors[i*4+2]=(byte)(icm.getRed(i)&0xff); } } drawDIBImage(getPrintDC(), image, destX, destY, destWidth, destHeight, srcX, srcY, srcWidth, srcHeight, bitCount, bmiColors); }
Example 8
Source File: WPrinterJob.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
protected void drawDIBImage(byte[] image, float destX, float destY, float destWidth, float destHeight, float srcX, float srcY, float srcWidth, float srcHeight, int sampleBitsPerPixel, IndexColorModel icm) { int bitCount = 24; byte[] bmiColors = null; if (icm != null) { bitCount = sampleBitsPerPixel; bmiColors = new byte[(1<<icm.getPixelSize())*4]; for (int i=0;i<icm.getMapSize(); i++) { bmiColors[i*4+0]=(byte)(icm.getBlue(i)&0xff); bmiColors[i*4+1]=(byte)(icm.getGreen(i)&0xff); bmiColors[i*4+2]=(byte)(icm.getRed(i)&0xff); } } drawDIBImage(getPrintDC(), image, destX, destY, destWidth, destHeight, srcX, srcY, srcWidth, srcHeight, bitCount, bmiColors); }
Example 9
Source File: WPrinterJob.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
protected void drawDIBImage(byte[] image, float destX, float destY, float destWidth, float destHeight, float srcX, float srcY, float srcWidth, float srcHeight, int sampleBitsPerPixel, IndexColorModel icm) { int bitCount = 24; byte[] bmiColors = null; if (icm != null) { bitCount = sampleBitsPerPixel; bmiColors = new byte[(1<<icm.getPixelSize())*4]; for (int i=0;i<icm.getMapSize(); i++) { bmiColors[i*4+0]=(byte)(icm.getBlue(i)&0xff); bmiColors[i*4+1]=(byte)(icm.getGreen(i)&0xff); bmiColors[i*4+2]=(byte)(icm.getRed(i)&0xff); } } drawDIBImage(getPrintDC(), image, destX, destY, destWidth, destHeight, srcX, srcY, srcWidth, srcHeight, bitCount, bmiColors); }
Example 10
Source File: WPrinterJob.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
protected void drawDIBImage(byte[] image, float destX, float destY, float destWidth, float destHeight, float srcX, float srcY, float srcWidth, float srcHeight, int sampleBitsPerPixel, IndexColorModel icm) { int bitCount = 24; byte[] bmiColors = null; if (icm != null) { bitCount = sampleBitsPerPixel; bmiColors = new byte[(1<<icm.getPixelSize())*4]; for (int i=0;i<icm.getMapSize(); i++) { bmiColors[i*4+0]=(byte)(icm.getBlue(i)&0xff); bmiColors[i*4+1]=(byte)(icm.getGreen(i)&0xff); bmiColors[i*4+2]=(byte)(icm.getRed(i)&0xff); } } drawDIBImage(getPrintDC(), image, destX, destY, destWidth, destHeight, srcX, srcY, srcWidth, srcHeight, bitCount, bmiColors); }
Example 11
Source File: WPrinterJob.java From hottub with GNU General Public License v2.0 | 5 votes |
protected void drawDIBImage(byte[] image, float destX, float destY, float destWidth, float destHeight, float srcX, float srcY, float srcWidth, float srcHeight, int sampleBitsPerPixel, IndexColorModel icm) { int bitCount = 24; byte[] bmiColors = null; if (icm != null) { bitCount = sampleBitsPerPixel; bmiColors = new byte[(1<<icm.getPixelSize())*4]; for (int i=0;i<icm.getMapSize(); i++) { bmiColors[i*4+0]=(byte)(icm.getBlue(i)&0xff); bmiColors[i*4+1]=(byte)(icm.getGreen(i)&0xff); bmiColors[i*4+2]=(byte)(icm.getRed(i)&0xff); } } drawDIBImage(getPrintDC(), image, destX, destY, destWidth, destHeight, srcX, srcY, srcWidth, srcHeight, bitCount, bmiColors); }
Example 12
Source File: WPrinterJob.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
protected void drawDIBImage(byte[] image, float destX, float destY, float destWidth, float destHeight, float srcX, float srcY, float srcWidth, float srcHeight, int sampleBitsPerPixel, IndexColorModel icm) { int bitCount = 24; byte[] bmiColors = null; if (icm != null) { bitCount = sampleBitsPerPixel; bmiColors = new byte[(1<<icm.getPixelSize())*4]; for (int i=0;i<icm.getMapSize(); i++) { bmiColors[i*4+0]=(byte)(icm.getBlue(i)&0xff); bmiColors[i*4+1]=(byte)(icm.getGreen(i)&0xff); bmiColors[i*4+2]=(byte)(icm.getRed(i)&0xff); } } drawDIBImage(getPrintDC(), image, destX, destY, destWidth, destHeight, srcX, srcY, srcWidth, srcHeight, bitCount, bmiColors); }
Example 13
Source File: WPrinterJob.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
protected void drawDIBImage(byte[] image, float destX, float destY, float destWidth, float destHeight, float srcX, float srcY, float srcWidth, float srcHeight, int sampleBitsPerPixel, IndexColorModel icm) { int bitCount = 24; byte[] bmiColors = null; if (icm != null) { bitCount = sampleBitsPerPixel; bmiColors = new byte[(1<<icm.getPixelSize())*4]; for (int i=0;i<icm.getMapSize(); i++) { bmiColors[i*4+0]=(byte)(icm.getBlue(i)&0xff); bmiColors[i*4+1]=(byte)(icm.getGreen(i)&0xff); bmiColors[i*4+2]=(byte)(icm.getRed(i)&0xff); } } drawDIBImage(getPrintDC(), image, destX, destY, destWidth, destHeight, srcX, srcY, srcWidth, srcHeight, bitCount, bmiColors); }
Example 14
Source File: WPrinterJob.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
protected void drawDIBImage(byte[] image, float destX, float destY, float destWidth, float destHeight, float srcX, float srcY, float srcWidth, float srcHeight, int sampleBitsPerPixel, IndexColorModel icm) { int bitCount = 24; byte[] bmiColors = null; if (icm != null) { bitCount = sampleBitsPerPixel; bmiColors = new byte[(1<<icm.getPixelSize())*4]; for (int i=0;i<icm.getMapSize(); i++) { bmiColors[i*4+0]=(byte)(icm.getBlue(i)&0xff); bmiColors[i*4+1]=(byte)(icm.getGreen(i)&0xff); bmiColors[i*4+2]=(byte)(icm.getRed(i)&0xff); } } drawDIBImage(getPrintDC(), image, destX, destY, destWidth, destHeight, srcX, srcY, srcWidth, srcHeight, bitCount, bmiColors); }
Example 15
Source File: WPrinterJob.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
protected void drawDIBImage(byte[] image, float destX, float destY, float destWidth, float destHeight, float srcX, float srcY, float srcWidth, float srcHeight, int sampleBitsPerPixel, IndexColorModel icm) { int bitCount = 24; byte[] bmiColors = null; if (icm != null) { bitCount = sampleBitsPerPixel; bmiColors = new byte[(1<<icm.getPixelSize())*4]; for (int i=0;i<icm.getMapSize(); i++) { bmiColors[i*4+0]=(byte)(icm.getBlue(i)&0xff); bmiColors[i*4+1]=(byte)(icm.getGreen(i)&0xff); bmiColors[i*4+2]=(byte)(icm.getRed(i)&0xff); } } drawDIBImage(getPrintDC(), image, destX, destY, destWidth, destHeight, srcX, srcY, srcWidth, srcHeight, bitCount, bmiColors); }
Example 16
Source File: WPrinterJob.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
protected void drawDIBImage(byte[] image, float destX, float destY, float destWidth, float destHeight, float srcX, float srcY, float srcWidth, float srcHeight, int sampleBitsPerPixel, IndexColorModel icm) { int bitCount = 24; byte[] bmiColors = null; if (icm != null) { bitCount = sampleBitsPerPixel; bmiColors = new byte[(1<<icm.getPixelSize())*4]; for (int i=0;i<icm.getMapSize(); i++) { bmiColors[i*4+0]=(byte)(icm.getBlue(i)&0xff); bmiColors[i*4+1]=(byte)(icm.getGreen(i)&0xff); bmiColors[i*4+2]=(byte)(icm.getRed(i)&0xff); } } drawDIBImage(getPrintDC(), image, destX, destY, destWidth, destHeight, srcX, srcY, srcWidth, srcHeight, bitCount, bmiColors); }