1 31 package org.pdfbox.pdmodel.graphics.color; 32 33 import java.awt.color.ColorSpace ; 34 35 import java.awt.image.ColorModel ; 36 import java.awt.image.ComponentColorModel ; 37 import java.awt.image.DataBuffer ; 38 import java.awt.Transparency ; 39 40 import java.io.IOException ; 41 42 48 public class PDDeviceGray extends PDColorSpace 49 { 50 53 public static final String NAME = "DeviceGray"; 54 55 58 public static final String ABBREVIATED_NAME = "G"; 59 60 65 public String getName() 66 { 67 return NAME; 68 } 69 70 77 public int getNumberOfComponents() throws IOException 78 { 79 return 1; 80 } 81 82 89 public ColorSpace createColorSpace() throws IOException 90 { 91 return ColorSpace.getInstance( ColorSpace.CS_GRAY ); 92 } 93 94 103 public ColorModel createColorModel( int bpc ) throws IOException 104 { 105 ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY); 106 int[] nBits = {bpc}; 107 ColorModel colorModel = new ComponentColorModel (cs, nBits, false,false, 108 Transparency.OPAQUE,DataBuffer.TYPE_BYTE); 109 return colorModel; 110 111 } 112 } | Popular Tags |