public void writeObject(PDFWriter out) { int length = 0; for (TempBuffer ptr = _jpegHead; ptr != null; ptr = ptr.getNext()) { length += ptr.getLength(); } @out.println("<< /Type /XObject"); @out.println(" /Subtype /Image"); @out.println(" /Width " + _width); @out.println(" /Height " + _height); @out.println(" /ColorSpace /DeviceRGB"); @out.println(" /BitsPerComponent " + _bits); @out.println(" /Filter /DCTDecode"); @out.println(" /Length " + length); @out.println(">>"); @out.println("stream"); for (TempBuffer ptr = _jpegHead; ptr != null; ptr = ptr.getNext()) { @out.write(ptr.getBuffer(), 0, ptr.getLength()); } @out.println(); @out.println("endstream"); }
/** * Returns the buffer contents. */ public Value getContents() { try { _out.flush(); StringValue bb = _env.createBinaryBuilder(_tempStream.getLength()); for (TempBuffer ptr = _tempStream.getHead(); ptr != null; ptr = ptr.getNext()) { bb.append(ptr.getBuffer(), 0, ptr.getLength()); } return(bb); } catch (IOException e) { _env.error(e.ToString(), e); return(BooleanValue.FALSE); } }
/** * Returns the result as a string. */ public Value get_buffer(Env env) { TempStream ts = _tempStream; _tempStream = null; if (ts == null) { return(BooleanValue.FALSE); } StringValue result = env.createBinaryBuilder(); for (TempBuffer ptr = ts.getHead(); ptr != null; ptr = ptr.getNext()) { result.append(ptr.getBuffer(), 0, ptr.getLength()); } ts.destroy(); return(result); }