1 31 package org.pdfbox.pdmodel.graphics.color; 32 33 import java.awt.Transparency ; 34 35 import java.awt.color.ColorSpace ; 36 37 import java.awt.image.ColorModel ; 38 import java.awt.image.ComponentColorModel ; 39 import java.awt.image.DataBuffer ; 40 41 import java.io.IOException ; 42 43 49 public class PDDeviceRGB extends PDColorSpace 50 { 51 54 public static final String NAME = "DeviceRGB"; 55 56 59 public static final String ABBREVIATED_NAME = "RGB"; 60 61 64 public static final PDDeviceRGB INSTANCE = new PDDeviceRGB(); 65 66 69 private PDDeviceRGB() 70 { 71 } 73 74 79 public String getName() 80 { 81 return NAME; 82 } 83 84 91 public int getNumberOfComponents() throws IOException 92 { 93 return 3; 94 } 95 96 103 public ColorSpace createColorSpace() throws IOException 104 { 105 return ColorSpace.getInstance( ColorSpace.CS_sRGB ); 106 } 107 108 117 public ColorModel createColorModel( int bpc ) throws IOException 118 { 119 int[] nbBits = { bpc, bpc, bpc }; 120 ComponentColorModel componentColorModel = 121 new ComponentColorModel ( createColorSpace(), 122 nbBits, 123 false, 124 false, 125 Transparency.OPAQUE, 126 DataBuffer.TYPE_BYTE ); 127 128 return componentColorModel; 129 } 130 } | Popular Tags |