public static BitmapSource LoadImage2(string KfbioAddress, string zoom, string posx, string posy) { try { MemoryStream memoryStream = null; int nDataLength = 0; IMAGE_INFO_STRUCT k = default(IMAGE_INFO_STRUCT); k.DataFilePTR = int.Parse(KfbioAddress); DllImageFuc.GetImageStreamFunc(ref k, float.Parse(zoom), int.Parse(posx), int.Parse(posy), ref nDataLength, out IntPtr datas); byte[] array = new byte[nDataLength]; if (datas != IntPtr.Zero) { Marshal.Copy(datas, array, 0, nDataLength); } DllImageFuc.DeleteImageDataFunc(datas); BitmapImage bitmapImage = new BitmapImage(); memoryStream = new MemoryStream(array); bitmapImage.BeginInit(); bitmapImage.CreateOptions = BitmapCreateOptions.PreservePixelFormat; bitmapImage.CacheOption = BitmapCacheOption.None; bitmapImage.StreamSource = memoryStream; bitmapImage.EndInit(); bitmapImage.Freeze(); return(bitmapImage); } catch (FileNotFoundException) { } catch (FileFormatException) { } return(null); }
public MagicZoomTileSource1(int imageWidth, int imageHeight, int tileWidth, int overlap, IMAGE_INFO_STRUCT infoStruct, float zoom, MultiScaleImage msi) : base(imageWidth, imageHeight, tileWidth, overlap) { InfoStruct = infoStruct; width = imageWidth; height = imageHeight; Xzoom = zoom; TileWidth = tileWidth; Msi = msi; }
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); } }
/// <summary> /// 获取瓦片图 /// </summary> /// <param name="k">地址</param> /// <param name="fScale">缩放比例</param> /// <param name="nImagePosX">瓦片图的坐标:X</param> /// <param name="nImagePosY">瓦片图的坐标:Y</param> /// <param name="nDataLength">图片的字节长度</param> /// <param name="datas">图片的byte</param> /// <returns></returns> public bool CkGetImageStreamFunc(ref IMAGE_INFO_STRUCT k, float fScale, int nImagePosX, int nImagePosY, ref int nDataLength, out IntPtr datas) { return(GetImageStreamFunc(ref k, fScale, nImagePosX, nImagePosY, ref nDataLength, out datas)); }
/// <summary> /// 读取kfb文件的总大小 /// </summary> /// <param name="k">文件的地址</param> /// <param name="p">kfb文件的完整路径</param> /// <returns></returns> public bool CkInitImageFileFunc(ref IMAGE_INFO_STRUCT k, string p) { return(InitImageFileFunc(ref k, p)); }
/// <summary> /// 获取二维码信息 /// </summary> public bool CkGetLableInfoFunc(IMAGE_INFO_STRUCT k, out IntPtr datas, ref int a, ref int b, ref int c) { return(GetLableInfoFunc(k, out datas, ref a, ref b, ref c)); }
/// <summary> /// 获取文件的头部信息 /// </summary> /// <param name="k">文件地址</param> /// <param name="khiImageHeight">图像高度</param> /// <param name="khiImageWidth">图像宽度</param> /// <param name="khiScanScale">扫描倍率:20还是40</param> /// <param name="khiSpendTime">消耗时间</param> /// <param name="khiScanTime">扫描时间</param> /// <param name="khiImageCapRes"></param> /// <param name="TileSize">瓦片图的大小</param> /// <returns></returns> public bool CkGetHeaderInfoFunc(IMAGE_INFO_STRUCT k, ref int khiImageHeight, ref int khiImageWidth, ref int khiScanScale, ref float khiSpendTime, ref double khiScanTime, ref float khiImageCapRes, ref int TileSize) { return(GetHeaderInfoFunc(k, ref khiImageHeight, ref khiImageWidth, ref khiScanScale, ref khiSpendTime, ref khiScanTime, ref khiImageCapRes, ref TileSize)); }
public bool CkUnInitImageFileFunc(ref IMAGE_INFO_STRUCT k) { return(UnInitImageFileFunc(ref k)); }
public static extern bool GetHeaderInfoFunc(IMAGE_INFO_STRUCT k, ref int khiImageHeight, ref int khiImageWidth, ref int khiScanScale, ref float khiSpendTime, ref double khiScanTime, ref float khiImageCapRes, ref int TileSize);
public static extern bool GetHSVImage(ref IMAGE_INFO_STRUCT kfbPoint, float fScale, int nImagePosX, int nImagePosY, ref int nDataLength, out IntPtr datas, int S_shift, int V_shift, int b, int b_r, int b_h, int r, int r_r, int r_h, float k, int sp);
public void SetinfoStruct(IMAGE_INFO_STRUCT infoStruct) { InfoStruct = infoStruct; }
public static extern void GetScanLevelInfoFunc(ref IMAGE_INFO_STRUCT k, ref int nCurLevel, ref int nTotalLevel);
public static extern bool GetVersionInfoFunc(ref IMAGE_INFO_STRUCT k, ref float f);
public static extern bool GetMachineSerialNumFunc(ref IMAGE_INFO_STRUCT k, IntPtr str);
public static extern bool GetImageStreamFunc(ref IMAGE_INFO_STRUCT k, float fScale, int nImagePosX, int nImagePosY, ref int nDataLength, out IntPtr datas);
public static extern bool UnInitImageFileFunc(ref IMAGE_INFO_STRUCT k);
public static extern bool InitImageFileFunc(ref IMAGE_INFO_STRUCT k, string p);
/// <summary> /// 获取版本信息 /// </summary> /// <param name="k">文件的地址</param> /// <param name="fScale">最大的层数</param> /// <returns></returns> public bool CkGetVersionInfoFunc(ref IMAGE_INFO_STRUCT k, ref float fScale) { return(GetVersionInfoFunc(ref k, ref fScale)); }
public static extern void GetImageDataRoiFunc(IMAGE_INFO_STRUCT k, float fScale, int x, int y, int width, int height, out IntPtr datas, ref int nDataLength, bool flag);
public static extern bool GetScanTimeDurationFunc(ref IMAGE_INFO_STRUCT k, ref int nYear, ref int nMonth, ref int nDay, ref int nHour, ref int nMiniter, ref int nSecond, ref int nDurHour, ref int nDurMin, ref int nDurSecond);
public static extern bool GetLableInfoFunc(IMAGE_INFO_STRUCT k, out IntPtr datas, ref int a, ref int b, ref int c);