public void write(int tagID, EMFOutputStream emf) throws IOException { emf.writeRECTL(bounds); emf.writeLONG(x); emf.writeLONG(y); emf.writeLONG(width); emf.writeLONG(height); dwROP.write(emf); emf.writeLONG(xSrc); emf.writeLONG(ySrc); emf.writeXFORM(transform); emf.writeCOLORREF(bkg); emf.writeDWORD(usage); emf.writeDWORD(size); // bmi follows this record immediately emf.writeDWORD(BitmapInfoHeader.size); emf.writeDWORD(size + BitmapInfoHeader.size); // bitmap follows bmi emf.pushBuffer(); int encode; // plain encode = BI_RGB; ImageGraphics2D.writeImage( (RenderedImage) image, ImageConstants.RAW.toLowerCase(), ImageGraphics2D.getRAWProperties(bkg, "*BGRA"), new NoCloseOutputStream(emf)); // emf.writeImage(image, bkg, "*BGRA", 1); // png // encode = BI_PNG; // ImageGraphics2D.writeImage(image, "png", new Properties(), new // NoCloseOutputStream(emf)); // jpg // encode = BI_JPEG; // ImageGraphics2D.writeImage(image, "jpg", new Properties(), new // NoCloseOutputStream(emf)); int length = emf.popBuffer(); emf.writeDWORD(length); emf.writeLONG(image.getWidth()); emf.writeLONG(image.getHeight()); BitmapInfoHeader header = new BitmapInfoHeader(image.getWidth(), image.getHeight(), 32, encode, length, 0, 0, 0, 0); bmi = new BitmapInfo(header); bmi.write(emf); emf.append(); }
public void write(int tagID, EMFOutputStream emf) throws IOException { emf.writeRECTL(bounds); emf.writeLONG(x); emf.writeLONG(y); emf.writeLONG(width); emf.writeLONG(height); emf.writeDWORD(dwROP); emf.writeLONG(xSrc); emf.writeLONG(ySrc); emf.writeXFORM(transform); emf.writeCOLORREF(bkg); emf.writeDWORD(usage); emf.writeDWORD(size); // bmi follows this record immediately emf.writeDWORD(BitmapInfoHeader.size); emf.writeDWORD(size + BitmapInfoHeader.size); // bitmap follows bmi emf.pushBuffer(); UserProperties properties = new UserProperties(); properties.setProperty(RawImageWriteParam.BACKGROUND, bkg); properties.setProperty(RawImageWriteParam.CODE, "BGR"); properties.setProperty(RawImageWriteParam.PAD, 4); ImageGraphics2D.writeImage(image, "raw", properties, new NoCloseOutputStream(emf)); // emf.writeImage(image, bkg, "BGR", 4); int length = emf.popBuffer(); BitmapInfoHeader header = new BitmapInfoHeader(image.getWidth(), image.getHeight(), 24, BI_RGB, length, 0, 0, 0, 0); bmi = new BitmapInfo(header); bmi.write(emf); emf.writeDWORD(length); emf.append(); }