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); } }
public static BitmapImage GetKFBPreView(string path) { IntPtr datas = IntPtr.Zero; int b = 0; int c = 0; int a = 0; DllImageFuc.GetPriviewInfoPathFunc(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 streamSource = new MemoryStream(array); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.CreateOptions = BitmapCreateOptions.PreservePixelFormat; bitmapImage.CacheOption = BitmapCacheOption.None; bitmapImage.StreamSource = streamSource; bitmapImage.EndInit(); bitmapImage.Freeze(); return(bitmapImage); }
public void GetChPdf(string templatePath, string newFilePath, Dictionary <string, string> parameters) { PdfReader pdfReader = new PdfReader(templatePath); PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(newFilePath, FileMode.Create)); AcroFields acroFields = pdfStamper.AcroFields; BaseFont value = BaseFont.CreateFont("C:\\Windows\\Fonts\\simsun.ttc,0", "Identity-H", true); foreach (KeyValuePair <string, string> parameter in parameters) { acroFields.SetFieldProperty(parameter.Key, "textfont", value, null); acroFields.SetField(parameter.Key, parameter.Value); } for (int i = 0; i < CheckList.Count; i++) { int nDataLength = 0; DllImageFuc.GetImageDataRoiFunc(InfoStruct, SlideZoom, CheckList[i].GlobalPosX, CheckList[i].GlobalPosY, CheckList[i].Width, CheckList[i].Height, out IntPtr datas, ref nDataLength, true); byte[] array = new byte[nDataLength]; if (datas != IntPtr.Zero) { Marshal.Copy(datas, array, 0, nDataLength); } DllImageFuc.DeleteImageDataFunc(datas); iTextSharp.text.Image instance = iTextSharp.text.Image.GetInstance(array); instance.ScaleAbsoluteWidth(40f); instance.ScaleAbsoluteHeight(40f); instance.SetAbsolutePosition(40 + i * 50 + 10, 400f); PdfContentByte overContent = pdfStamper.GetOverContent(1); overContent.AddImage(instance); } pdfStamper.FormFlattening = true; pdfStamper.Close(); pdfReader.Close(); }
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)); }
public Stream LoadImage(int KfbioAddress, int Level, int posx, int posy) { try { MemoryStream result = null; int nDataLength = 0; IMAGE_INFO_STRUCT k = default(IMAGE_INFO_STRUCT); k.DataFilePTR = KfbioAddress; int num = Math.Max(width, height); int num2 = IsInteger((Math.Log(num) / Math.Log(2.0)).ToString()) ? ((int)(Math.Log(num) / Math.Log(2.0))) : ((int)(Math.Log(num) / Math.Log(2.0)) + 1); float fScale = (num2 != Level) ? (Xzoom / (float)Math.Pow(2.0, num2 - Level)) : Xzoom; try { IntPtr datas; if (!isopenhsl) { DllImageFuc.GetImageStreamFunc(ref k, fScale, posx * TileWidth, posy * TileWidth, ref nDataLength, out datas); } else { DllImageFuc.GetHSVImage(ref k, fScale, posx * TileWidth, posy * TileWidth, ref nDataLength, out datas, S_shift, V_shift, b, b_r, b_h, r, r_r, r_h, dbd, sp); } byte[] array = new byte[nDataLength]; if (datas != IntPtr.Zero) { Marshal.Copy(datas, array, 0, nDataLength); } DllImageFuc.DeleteImageDataFunc(datas); result = new MemoryStream(array); } catch (Exception ex) { Console.WriteLine("zz" + ex.ToString() + nDataLength); } return(result); } catch (FileNotFoundException) { } catch (FileFormatException) { } return(null); }
public static bool CheckVersion(string filepath) { try { int num = 11; try { float f = 0f; DllImageFuc.GetDllVersionFunc(ref f); num = (int)(Math.Round(f, 1) * 10.0); } catch { } DllImageFuc dllImageFuc = new DllImageFuc(); IMAGE_INFO_STRUCT k = default(IMAGE_INFO_STRUCT); k.DataFilePTR = 0; dllImageFuc.CkInitImageFileFunc(ref k, filepath); float fScale = 0f; dllImageFuc.CkGetVersionInfoFunc(ref k, ref fScale); int num2 = (int)(fScale * 10f); if (num2 > num) { MessageWind messageWind = new MessageWind(MessageBoxButton.OK, System.Windows.Application.Current.MainWindow, ((DockWindow)System.Windows.Application.Current.MainWindow).languageSetter.LanguageResource["Filedamage2"], ((DockWindow)System.Windows.Application.Current.MainWindow).languageSetter.LanguageResource["Prompt"], MessageBoxIcon.Exclamation, false); messageWind.ShowDialog(); return(false); } if (num2 == 0) { MessageWind messageWind2 = new MessageWind(MessageBoxButton.OK, System.Windows.Application.Current.MainWindow, ((DockWindow)System.Windows.Application.Current.MainWindow).languageSetter.LanguageResource["Filedamage"], ((DockWindow)System.Windows.Application.Current.MainWindow).languageSetter.LanguageResource["Prompt"], MessageBoxIcon.Exclamation, false); messageWind2.ShowDialog(); return(false); } return(true); } catch (Exception e) { System.Windows.MessageBox.Show(e.Message); MessageWind messageWind3 = new MessageWind(MessageBoxButton.OK, System.Windows.Application.Current.MainWindow, ((DockWindow)System.Windows.Application.Current.MainWindow).languageSetter.LanguageResource["Filedamage2"], ((DockWindow)System.Windows.Application.Current.MainWindow).languageSetter.LanguageResource["Prompt"], MessageBoxIcon.Exclamation, false); messageWind3.ShowDialog(); return(false); } }