예제 #1
0
 private void ReadPng(TImage aImage)
 {
     using (MemoryStream Ms = new MemoryStream())
     {
         aImage.Save(Ms, System.Drawing.Imaging.ImageFormat.Png);
         Ms.Position = 0;
         ReadPng(Ms);
     }
 }
예제 #2
0
        private void ReadJpeg(TImage aImage, Stream aImageData)
        {
            MemoryStream Msi = (aImageData as MemoryStream);

            if (Msi != null)
            {
                FImage = Msi.ToArray();
            }
            else
            {
                FImage = null;
            }
            FBitsPerComponent = 8;
            FDecodeParmsName  = null;
            FDecodeParmsSMask = null;
            if (aImage.PixelFormat == PixelFormat.Format8bppIndexed)
            {
                FColorSpace = TPdfTokens.GetString(TPdfToken.DeviceGrayName);
            }
            else
            {
                FColorSpace = TPdfTokens.GetString(TPdfToken.DeviceRGBName);                 //We don't care what the JPEG suggested colorspace is (in APPE/X'FFEE), we will show this on RGB. (Internally, JPEG Colorspace is always YCC)
            }
            FFilterName  = TPdfTokens.GetString(TPdfToken.DCTDecodeName);
            FImageWidth  = aImage.Width;
            FImageHeight = aImage.Height;
            if (FImage == null)
            {
                using (MemoryStream Ms = new MemoryStream())
                {
                    aImage.Save(Ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                    FImage = Ms.ToArray();
                }
            }

            if (FTransparentColor != ~0L)
            {
                int r = (int)((FTransparentColor >> 0) & 0xFF);
                int g = (int)((FTransparentColor >> 8) & 0xFF);
                int b = (int)((FTransparentColor >> 16) & 0xFF);
                FMask =
                    TPdfTokens.GetString(TPdfToken.OpenArray) +
                    String.Format(CultureInfo.InvariantCulture, "{0} {1} {2} {3} {4} {5}", Math.Max(r - 15, 0), Math.Min(r + 15, 255), Math.Max(g - 15, 0), Math.Min(g + 15, 255), Math.Max(b - 15, 0), Math.Min(b + 15, 255)) +
                    TPdfTokens.GetString(TPdfToken.CloseArray);
            }
        }