コード例 #1
0
ファイル: RtfImage.cs プロジェクト: pixelia-es/RazorPDF2
        /**
        * Extracts the image data from the Image.
        *
        * @param image The image for which to extract the content
        * @return The raw image data, not formated
        * @throws DocumentException If an error occurs accessing the image content
        */
        private byte[][] GetImageData(Image image)
        {
            int WMF_PLACEABLE_HEADER_SIZE = 22;
            RtfByteArrayBuffer bab = new RtfByteArrayBuffer();

            try {
                if (imageType == Image.ORIGINAL_BMP) {
                    bab.Append(MetaDo.WrapBMP(image));
                } else {
                    byte[] iod = image.OriginalData;
                    if (iod == null) {
                        Stream imageIn = WebRequest.Create(image.Url).GetResponse().GetResponseStream();
                        if (imageType == Image.ORIGINAL_WMF) { //remove the placeable header first
                            for (int k = 0; k < WMF_PLACEABLE_HEADER_SIZE; k++) {
                                if (imageIn.ReadByte() < 0) throw (new IOException("while removing wmf placeable header"));
                            }
                        }
                        bab.Write(imageIn);
                        imageIn.Close();

                    } else {

                        if (imageType == Image.ORIGINAL_WMF) {
                            //remove the placeable header
                            bab.Write(iod, WMF_PLACEABLE_HEADER_SIZE, iod.Length - WMF_PLACEABLE_HEADER_SIZE);
                        } else {
                            bab.Append(iod);
                        }

                    }
                }
                return bab.ToArrayArray();
            } catch (IOException ioe) {
                throw new DocumentException(ioe.Message);
            }
        }
コード例 #2
0
 /**
 * Constructs a RtfMemoryCache.
 */
 public RtfEfficientMemoryCache()
 {
     bab = new RtfByteArrayBuffer();
 }
コード例 #3
0
 /**
  * Constructs a RtfMemoryCache.
  */
 public RtfEfficientMemoryCache()
 {
     bab = new RtfByteArrayBuffer();
 }