Beispiel #1
0
        private FreeImageBitmap CreateFreeImageViaDIB()
        {
            FreeImageBitmap fi;

            using (DllManager dllManager = new DllManager())
            {
                dllManager.LoadDll("FreeImage.DLL");
                Logger.Info("CreateFreeImageViaDIB: Copy to clipboard and get data from it");
                if (!CopySelection())
                {
                    return(null);
                }

                MemoryStream stream = Clipboard.GetData(System.Windows.DataFormats.Dib) as MemoryStream;
                using (DibBitmap dibBitmap = new DibBitmap(stream))
                {
                    Logger.Info("CreateFreeImageViaDIB: Create FreeImage bitmap");
                    fi = new FreeImageBitmap(dibBitmap.Bitmap);
                    bool convertType = fi.ConvertType(FREE_IMAGE_TYPE.FIT_BITMAP, true);
                    Logger.Debug("CreateFreeImageViaDIB: FreeImageBitmap.ConvertType returned {0}", convertType);
                    bool convertColorDepth = fi.ConvertColorDepth(FREE_IMAGE_COLOR_DEPTH.FICD_24_BPP); // won't work with 32 bpp!
                    Logger.Debug("CreateFreeImageViaDIB: FreeImageBitmap.ConvertColorDepth returned {0}", convertColorDepth);
                    fi.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipY);
                }
            }
            return(fi);
        }
Beispiel #2
0
        private FreeImageBitmap CreateFreeImageViaDIB()
        {
            if (!CopySelection())
            {
                return(null);
            }
            FreeImageBitmap fi;
            MemoryStream    stream = null;

            Bovender.WpfHelpers.MainDispatcher.Invoke((Action)(
                                                          () =>
            {
                Logger.Info("CreateFreeImageViaDIB: Copy to clipboard and get data from it");
                stream = Clipboard.GetData(System.Windows.DataFormats.Dib) as MemoryStream;
            })
                                                      );
            using (DibBitmap dibBitmap = new DibBitmap(stream))
            {
                Logger.Info("CreateFreeImageViaDIB: Create FreeImage bitmap");
                fi = new FreeImageBitmap(dibBitmap.Bitmap);
                bool convertType = fi.ConvertType(FREE_IMAGE_TYPE.FIT_BITMAP, true);
                Logger.Debug("CreateFreeImageViaDIB: FreeImageBitmap.ConvertType returned {0}", convertType);
                bool convertColorDepth = fi.ConvertColorDepth(FREE_IMAGE_COLOR_DEPTH.FICD_24_BPP); // won't work with 32 bpp!
                Logger.Debug("CreateFreeImageViaDIB: FreeImageBitmap.ConvertColorDepth returned {0}", convertColorDepth);
                fi.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipY);
            }
            stream.Dispose();
            return(fi);
        }