Example #1
0
        public static FreeImageBitmap LoadImage(Stream ajpStream)
        {
            MemoryStream jpegFile;
            MemoryStream pmsFile;
            AjpHeader    ajpHeader;

            LoadImage(ajpStream, out jpegFile, out pmsFile, out ajpHeader);
            if (jpegFile == null)
            {
                return(null);
            }

            jpegFile.Position = 0;
            FreeImageBitmap jpegImage = new FreeImageBitmap(jpegFile, FREE_IMAGE_FORMAT.FIF_JPEG);

            jpegImage.Tag     = ajpHeader;
            jpegImage.Comment = ajpHeader.GetComment();

            if (pmsFile != null && pmsFile.Length > 0)
            {
                pmsFile.Position = 0;
                using (var pmsImage = Pms.LoadImage(pmsFile.ToArray()))
                {
                    if (pmsImage == null)
                    {
                        return(jpegImage);
                    }
                    jpegImage.ConvertColorDepth(FREE_IMAGE_COLOR_DEPTH.FICD_32_BPP);
                    jpegImage.SetChannel(pmsImage, FREE_IMAGE_COLOR_CHANNEL.FICC_ALPHA);
                }
            }

            return(jpegImage);
        }
Example #2
0
        public static void LoadImage(Stream ajpStream, out byte[] jpegBytes, out FreeImageBitmap alpha, out AjpHeader ajpHeader)
        {
            MemoryStream jpegFile;
            MemoryStream pmsFile;

            LoadImage(ajpStream, out jpegFile, out pmsFile, out ajpHeader);
            jpegBytes = jpegFile.ToArray();
            jpegFile.Dispose();

            alpha = null;
            if (pmsFile != null)
            {
                FreeImageBitmap pmsImage = Pms.LoadImage(pmsFile.ToArray());
                pmsFile.Dispose();
                alpha = pmsImage;
            }
        }