1 17 18 19 20 package org.apache.fop.render.afp.modca; 21 import java.io.IOException ; 22 import java.io.OutputStream ; 23 import java.io.UnsupportedEncodingException ; 24 25 38 public class IMImageObject extends AbstractNamedAFPObject { 39 40 43 private ImageOutputControl _imageOutputControl = null; 44 45 48 private ImageInputDescriptor _imageInputDescriptor = null; 49 50 53 private ImageCellPosition _imageCellPosition = null; 54 55 58 private ImageRasterData _imageRastorData = null; 59 60 65 public IMImageObject(String name) { 66 67 super(name); 68 69 } 70 71 75 public void setImageOutputControl(ImageOutputControl imageOutputControl) { 76 _imageOutputControl = imageOutputControl; 77 } 78 79 83 public void setImageCellPosition(ImageCellPosition imageCellPosition) { 84 _imageCellPosition = imageCellPosition; 85 } 86 87 91 public void setImageInputDescriptor(ImageInputDescriptor imageInputDescriptor) { 92 _imageInputDescriptor = imageInputDescriptor; 93 } 94 95 99 public void setImageRasterData(ImageRasterData imageRastorData) { 100 _imageRastorData = imageRastorData; 101 } 102 103 108 public void writeDataStream(OutputStream os) 109 throws IOException { 110 111 writeStart(os); 112 113 if (_imageOutputControl != null) { 114 _imageOutputControl.writeDataStream(os); 115 } 116 117 if (_imageInputDescriptor != null) { 118 _imageInputDescriptor.writeDataStream(os); 119 } 120 121 if (_imageCellPosition != null) { 122 _imageCellPosition.writeDataStream(os); 123 } 124 125 if (_imageRastorData != null) { 126 _imageRastorData.writeDataStream(os); 127 } 128 129 writeEnd(os); 130 131 } 132 133 137 private void writeStart(OutputStream os) 138 throws IOException { 139 140 byte[] data = new byte[17]; 141 142 data[0] = 0x5A; data[1] = 0x00; data[2] = 0x10; data[3] = (byte) 0xD3; data[4] = (byte) 0xA8; data[5] = (byte) 0x7B; data[6] = 0x00; data[7] = 0x00; data[8] = 0x00; 152 for (int i = 0; i < _nameBytes.length; i++) { 153 154 data[9 + i] = _nameBytes[i]; 155 156 } 157 158 os.write(data); 159 160 } 161 162 166 private void writeEnd(OutputStream os) 167 throws IOException { 168 169 byte[] data = new byte[17]; 170 171 data[0] = 0x5A; data[1] = 0x00; data[2] = 0x10; data[3] = (byte) 0xD3; data[4] = (byte) 0xA9; data[5] = (byte) 0x7B; data[6] = 0x00; data[7] = 0x00; data[8] = 0x00; 181 for (int i = 0; i < _nameBytes.length; i++) { 182 183 data[9 + i] = _nameBytes[i]; 184 185 } 186 187 os.write(data); 188 189 } 190 191 } 192 | Popular Tags |