/** * Convert from split R, G, B values to an integer RGB value */ public static int joinRGB(byte r, byte g, byte b) { return joinRGB(new byte[] { r,g,b }); } /**
/** * Write the contents of the record back, so it can be written * to disk */ public void writeOut(OutputStream out) throws IOException { // Header - size or type unchanged out.write(_header); // Write out the rgb values writeLittleEndian(backgroundColourRGB,out); writeLittleEndian(textAndLinesColourRGB,out); writeLittleEndian(shadowsColourRGB,out); writeLittleEndian(titleTextColourRGB,out); writeLittleEndian(fillsColourRGB,out); writeLittleEndian(accentColourRGB,out); writeLittleEndian(accentAndHyperlinkColourRGB,out); writeLittleEndian(accentAndFollowingHyperlinkColourRGB,out); }
protected static Color getColorFromColorIndexStruct(int rgb, HSLFSheet sheet) { int cidx = rgb >>> 24; Color tmp; switch (cidx) { // Background ... Accent 3 color case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: if (sheet == null) { return null; } ColorSchemeAtom ca = sheet.getColorScheme(); tmp = new Color(ca.getColor(cidx), true); break; // Color is an sRGB value specified by red, green, and blue fields. case 0xFE: tmp = new Color(rgb, true); break; // Color is undefined. default: case 0xFF: return null; } return new Color(tmp.getBlue(), tmp.getGreen(), tmp.getRed()); }
/** * Create a new, empty, Slide, along with its required * child records. */ public Slide(){ _header = new byte[8]; LittleEndian.putUShort(_header, 0, 15); LittleEndian.putUShort(_header, 2, (int)_type); LittleEndian.putInt(_header, 4, 0); slideAtom = new SlideAtom(); ppDrawing = new PPDrawing(); ColorSchemeAtom colorAtom = new ColorSchemeAtom(); _children = new Record[] { slideAtom, ppDrawing, colorAtom }; }
/** * @return font color as RGB value * @see java.awt.Color */ public Color getFontColor() { int rgb = getCharTextPropVal("font.color"); int cidx = rgb >> 24; if (rgb % 0x1000000 == 0){ ColorSchemeAtom ca = parentRun.getSheet().getColorScheme(); if(cidx >= 0 && cidx <= 7) rgb = ca.getColor(cidx); } Color tmp = new Color(rgb, true); return new Color(tmp.getBlue(), tmp.getGreen(), tmp.getRed()); }
/** * Create a new, empty, Slide, along with its required * child records. */ public Slide(){ _header = new byte[8]; LittleEndian.putUShort(_header, 0, 15); LittleEndian.putUShort(_header, 2, (int)_type); LittleEndian.putInt(_header, 4, 0); slideAtom = new SlideAtom(); ppDrawing = new PPDrawing(); ColorSchemeAtom colorAtom = new ColorSchemeAtom(); _children = new Record[] { slideAtom, ppDrawing, colorAtom }; }
/** * Returns the bullet color */ public Color getBulletColor() { int rgb = getParaTextPropVal("bullet.color"); if(rgb == -1) return getFontColor(); int cidx = rgb >> 24; if (rgb % 0x1000000 == 0){ ColorSchemeAtom ca = parentRun.getSheet().getColorScheme(); if(cidx >= 0 && cidx <= 7) rgb = ca.getColor(cidx); } Color tmp = new Color(rgb, true); return new Color(tmp.getBlue(), tmp.getGreen(), tmp.getRed()); }
/** * Write the contents of the record back, so it can be written * to disk */ @Override public void writeOut(OutputStream out) throws IOException { // Header - size or type unchanged out.write(_header); // Write out the rgb values writeLittleEndian(backgroundColourRGB,out); writeLittleEndian(textAndLinesColourRGB,out); writeLittleEndian(shadowsColourRGB,out); writeLittleEndian(titleTextColourRGB,out); writeLittleEndian(fillsColourRGB,out); writeLittleEndian(accentColourRGB,out); writeLittleEndian(accentAndHyperlinkColourRGB,out); writeLittleEndian(accentAndFollowingHyperlinkColourRGB,out); }
/** * Convert from split R, G, B values to an integer RGB value */ public static int joinRGB(byte r, byte g, byte b) { return joinRGB(new byte[] { r,g,b }); } /**
Color toRGB(int val){ int a = (val >> 24) & 0xFF; int b = (val >> 16) & 0xFF; int g = (val >> 8) & 0xFF; int r = (val >> 0) & 0xFF; if(a == 0xFE){ // Color is an sRGB value specified by red, green, and blue fields. } else if (a == 0xFF){ // Color is undefined. } else { // index in the color scheme ColorSchemeAtom ca = getSheet().getColorScheme(); int schemeColor = ca.getColor(a); r = (schemeColor >> 0) & 0xFF; g = (schemeColor >> 8) & 0xFF; b = (schemeColor >> 16) & 0xFF; } return new Color(r, g, b); }
/** * Convert from an integer RGB value to individual R, G, B 0-255 values */ public static byte[] splitRGB(int rgb) { byte[] ret = new byte[3]; // Serialise to bytes, then grab the right ones out ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { writeLittleEndian(rgb,baos); } catch(IOException ie) { // Should never happen throw new RuntimeException(ie); } byte[] b = baos.toByteArray(); System.arraycopy(b,0,ret,0,3); return ret; }
Color toRGB(int val){ int a = (val >> 24) & 0xFF; int b = (val >> 16) & 0xFF; int g = (val >> 8) & 0xFF; int r = (val >> 0) & 0xFF; if(a == 0xFE){ // Color is an sRGB value specified by red, green, and blue fields. } else if (a == 0xFF){ // Color is undefined. } else { // index in the color scheme ColorSchemeAtom ca = getSheet().getColorScheme(); int schemeColor = ca.getColor(a); r = (schemeColor >> 0) & 0xFF; g = (schemeColor >> 8) & 0xFF; b = (schemeColor >> 16) & 0xFF; } return new Color(r, g, b); }
/** * Convert from an integer RGB value to individual R, G, B 0-255 values */ public static byte[] splitRGB(int rgb) { byte[] ret = new byte[3]; // Serialise to bytes, then grab the right ones out ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { writeLittleEndian(rgb,baos); } catch(IOException ie) { // Should never happen throw new HSLFException(ie); } byte[] b = baos.toByteArray(); System.arraycopy(b,0,ret,0,3); return ret; }
int schemeColor = ca.getColor(r);
int schemeColor = ca.getColor(ecr.getSchemeIndex());