예제 #1
0
        public static BitmapImage GetKFBThumnail(string path)
        {
            BitmapImage bitmapImage = new BitmapImage();

            try
            {
                DllImageFuc dllImageFuc = new DllImageFuc();
                IntPtr      datas       = IntPtr.Zero;
                int         b           = 0;
                int         c           = 0;
                int         a           = 0;
                dllImageFuc.CkGetThumnailImagePathFunc(path, out datas, ref a, ref b, ref c);
                byte[] array = new byte[a];
                if (datas != IntPtr.Zero)
                {
                    Marshal.Copy(datas, array, 0, a);
                }
                DllImageFuc.DeleteImageDataFunc(datas);
                MemoryStream ss = new MemoryStream(array);
                bitmapImage.BeginInit();
                bitmapImage.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
                bitmapImage.CacheOption   = BitmapCacheOption.None;
                bitmapImage.StreamSource  = ReizeImage(ss, 20.0);
                bitmapImage.EndInit();
                bitmapImage.Freeze();
                return(bitmapImage);
            }
            catch
            {
                return(bitmapImage);
            }
        }
예제 #2
0
        public Bitmap GetKFBThumnail(string path)
        {
            KFBIO.SlideViewer.DllImageFuc dllImageFuc = new KFBIO.SlideViewer.DllImageFuc();
            Bitmap   bitmap   = new Bitmap(120, 120, PixelFormat.Format24bppRgb);
            Graphics graphics = Graphics.FromImage(bitmap);

            graphics.Clear(Color.White);
            MemoryStream memoryStream = null;
            Bitmap       bitmap2      = null;
            Bitmap       bitmap3      = null;

            try
            {
                IntPtr datas = IntPtr.Zero;
                int    b     = 0;
                int    c     = 0;
                int    a     = 0;
                dllImageFuc.CkGetThumnailImagePathFunc(path, out datas, ref a, ref b, ref c);
                byte[] array = new byte[a];
                if (datas != IntPtr.Zero)
                {
                    Marshal.Copy(datas, array, 0, a);
                }
                dllImageFuc.CkDeleteImageDataFunc(datas);
                memoryStream = new MemoryStream(array);
                bitmap2      = new Bitmap(IconExtractor.ReizeImage(memoryStream, 50.0));
                string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
                Image  image         = Image.FromFile(baseDirectory + "images\\pp.png");
                graphics.DrawImage(image, 30, 0);
                graphics.Save();
                bitmap3 = new Bitmap(IconExtractor.ReizeImage(GetKFBLabel(path), 50.0));
                int width = bitmap3.Width;
                _ = bitmap3.Height;
                graphics.DrawImage(bitmap3, 30 + (60 - width) / 2, 5);
                graphics.Save();
                int width2 = bitmap2.Width;
                int height = bitmap2.Height;
                graphics.DrawImage(bitmap2, 30 + (60 - width2) / 2, 15 + (120 - height) / 2);
                graphics.Save();
            }
            catch
            {
                string baseDirectory2 = AppDomain.CurrentDomain.BaseDirectory;
                Image  image2         = Image.FromFile(baseDirectory2 + "images\\KViewerIcon_5_allSize.png");
                graphics.DrawImage(image2, 0, 0);
                graphics.Save();
                return(new Bitmap(bitmap));
            }
            return(new Bitmap(bitmap));
        }