⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdimage.cs

📁 c#代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
//+--------------------------------------------------------------------------+
//|                                                                          |
//|                             GDImage class                                |
//|                                                                          |
//+--------------------------------------------------------------------------+
//|                                                                          |
//|                         Author Patrice TERRIER                           |
//|                           copyright (c) 2006                             |
//|                                                                          |
//|                        pterrier@zapsolution.com                          |
//|                                                                          |
//|                          www.zapsolution.com                             |
//|                                                                          |
//+--------------------------------------------------------------------------+
//|                  Project started on : 10-17-2006 (MM-DD-YYYY)            |
//|                        Last revised : 10-25-2006 (MM-DD-YYYY)            |
//+--------------------------------------------------------------------------+

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

using System.Drawing;
using System.Windows.Forms;
using Win32;
using OpenGL;

namespace GDImage
{
    class GI
    {
        private const string GDIMAGE = @"gdimage.dll";

        public const string GDImageClassName = "ZIMAGECTRL";
        public const string GLImageClassName = "ZOPENGLCTRL";

        // ANCHOR properties
        public const int ANCHOR_NONE = 0;
        public const int ANCHOR_WIDTH = 1;
        public const int ANCHOR_RIGHT = 2;
        public const int ANCHOR_CENTER_HORZ = 3;
        public const int ANCHOR_HEIGHT = 4;
        public const int ANCHOR_HEIGHT_WIDTH = 5;
        public const int ANCHOR_HEIGHT_RIGHT = 6;
        public const int ANCHOR_BOTTOM = 7;
        public const int ANCHOR_BOTTOM_WIDTH = 8;
        public const int ANCHOR_BOTTOM_RIGHT = 9;
        public const int ANCHOR_CENTER_HORZ_BOTTOM = 10;
        public const int ANCHOR_CENTER_VERT = 11;
        public const int ANCHOR_CENTER_VERT_RIGHT = 12;
        public const int ANCHOR_CENTER = 13;

        // ZD_DrawText constants
        public const int ZD_TextHorzUp = 0x0;       // Horizontal text orientation
        public const int ZD_TextVertUp = 0x1;       // Vertical text orientation from bottom to top
        public const int ZD_TextVertDn = 0x2;       // Vertical text orientation from top to bottom
        public const int ZD_HIDE = 0x0;             // FALSE
        public const int ZD_SHOW = 0x1;             // TRUE

        public const int ZD_DRAW_REDRAW = -1;     // Forces immediat redraw of parent object
        public const int ZD_DRAW_DEFERRED = 0;      // Defers redraw of parent object

        // GDImage overlay Generic STYLE must be a 2^
        public const int ZS_HIDDEN = ZD_HIDE;
        public const int ZS_VISIBLE = ZD_SHOW;      // VISIBLE, same as WS_VISIBLE
        public const int ZS_SCROLL = 0x2;           // MOVE with scroll bars, default is FIX (do not scroll)
        public const int ZS_DRAFT = 0x4;            // Draft drawing mode

        public const int ZI_FitToWindow = 7;        // Resize the image to fit the view port
        // And use any of this constant as Parameter
        public const int ZI_QualityDefault = -1;
        public const int ZI_QualityGood = 1;        // Best performance
        public const int ZI_QualityHigh = 2;        // Best rendering quality

        public const int ZI_Horizontal = 3;         // Horizontal scrolling position
        public const int ZI_Vertical = 4;           // Vertical scrolling position
        public const int ZI_GradientTop = 5;        // Set/Get top gradiant color backgroud
        public const int ZI_GradientBottom = 6;     // Set/Get bottom gradiant color backgroud
        public const int ZI_ZoomWindow = 11;        // Set/Get zoom window status
        public const int ZI_Orientation = 13;       // Set/Get orientation 

        public const int RotateNoneFlipNone = 0;    // GDI+ constant
        public const int Rotate90FlipNone = 1;      // GDI+ constant
        public const int Rotate180FlipNone = 2;     // GDI+ constant
        public const int Rotate270FlipNone = 3;     // GDI+ constant
        public const int RotateNoneFlipX = 4;       // GDI+ constant
        public const int RotateNoneFlipY = 6;       // GDI+ constant

        [StructLayout(LayoutKind.Sequential)]
        public struct ZGLFONT
        {
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
            public string fontName; // The True Type font name.
            public int fontBase;    // The OpenGL FontBase (do not set this).
            public int charStart;   // OpenGL starting ASCII character (usually 32).
            public int charNum;     // OpenGL number of glyphe characters to create(usually 96).
            public int fontHeight;  // The font size (72 DPI).
            public int fontWeight;  // The font weigt.
            public int fontHandle;  // The Win32 font handle
        }

        [StructLayout(LayoutKind.Sequential)]
        public struct ZGLTEXTURE
        {
            public int ID;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = Api.MAX_PATH)]
            public string FullName;
            public int Texture;
        }

        [DllImport(GDIMAGE, EntryPoint = "ZI_UseGLPolarView")]
        public static extern void UseGLPolarView(double radius, double twist, double latitude, double longitude);

        [DllImport(GDIMAGE, EntryPoint = "ZI_GetImageSizeFromFile")]
        public static extern int GetImageSizeFromFile(string FullPathName, out int width, out int height);

        [DllImport(GDIMAGE, EntryPoint = "ZI_UpdateNamedGLTextureFromFile")]
        public static extern int UpdateNamedGLTextureFromFile(string zFullName, int NamedTexture);

        [DllImport(GDIMAGE, EntryPoint = "ZI_CreateMutipleGLtextures")]
        public static extern int CreateMutipleGLtextures(ref ZGLTEXTURE[] mt, int n);

        [DllImport(GDIMAGE, EntryPoint = "ZI_CreateMutiple32BitGLtextures")]
        public static extern int CreateMutiple32BitGLtextures(ref ZGLTEXTURE[] mt, int n);

        //[DllImport(GDIMAGE, EntryPoint = "ZI_CreateGLTextureFrom32Bit")]
        //public static extern int CreateGLTextureFrom32Bit(string zFullPath, ref int xSize, ref int ySize, ref byte[] PixelArray);
        
        [DllImport(GDIMAGE, EntryPoint = "ZI_BuildGLfont")]
        public static extern void BuildGLfont(int hDC, ref ZGLFONT Font);

        [DllImport(GDIMAGE, EntryPoint = "ZI_DeleteGLFont")]
        public static extern void DeleteGLFont(ref ZGLFONT Font);

        [DllImport(GDIMAGE, EntryPoint = "ZI_DrawGLText")]
        public static extern void DrawGLText(IntPtr hWnd, ref ZGLFONT Font, int x, int y, string zTxt, int ARGB);

        [DllImport(GDIMAGE, EntryPoint = "ZI_GetGLzoom")]
        public static extern int ZI_GetGLzoom(IntPtr hWnd);

        [DllImport(GDIMAGE, EntryPoint = "ZI_GetGLDC")]
        public static extern int GetGLDC(IntPtr hWnd);

        [DllImport(GDIMAGE, EntryPoint = "ZI_GetGLzoom")]
        public static extern int GetGLzoom(IntPtr hWnd);

        [DllImport(GDIMAGE, EntryPoint = "ZI_SetGLzoom")]
        public static extern void SetGLzoom(IntPtr hWnd, int fovy);

        [DllImport(GDIMAGE)]  // Register the GDImage Win32 class
        public static extern bool RegisterGLImageClass();

        //[DllImport(GDIMAGE)]
        //public static extern int ZI_CreateGLTextureFromFile(string zFullPath, ref int xSize, ref int ySize, byte[] PixelArray);

        [DllImport(GDIMAGE, EntryPoint = "ZI_DoNotSquareTexture")]
        public static extern void DoNotSquareTexture();

        [DllImport(GDIMAGE, EntryPoint = "ZI_SetGLTextureFromFile")]
        public static extern int SetGLTextureFromFile(string zFullName);

        [DllImport(GDIMAGE)]  // Register the GDImage Win32 class
        public static extern bool RegisterGDImageClass();

        [DllImport(GDIMAGE)]  // Load image from file
        public static extern void ZI_SetFromFile(
        IntPtr hCtrl,       // The GDImage control
        string zFullPath    // The control unique IDentifier
        );

        [DllImport(GDIMAGE, EntryPoint = "ZI_InitGLControl")]
        public static extern void InitGLControl(int ARGB);

        [DllImport(GDIMAGE)]  // Anchor control to the main window form
        public static extern void ZI_SetAnchorMode(
        IntPtr hCtrl,       // The GDImage control
        int AnchorMode      // The control unique IDentifier
        );

        // Dialog file selector with thumbnail preview 
        [DllImport(GDIMAGE, EntryPoint = "ZI_LoadDialog")]
        public static extern string LoadDialog(
        IntPtr hParent      // The Window/Dialog container
        );

        [DllImport(GDIMAGE, EntryPoint = "ZI_LoadSavePath")]
        public static extern string LoadSavePath(string zUseThisPath, bool RW);

        // Set property of a GDImage control
        [DllImport(GDIMAGE, EntryPoint = "ZI_SetProperty")]
        public static extern void SetProperty(
        IntPtr hCtrl,       // The GDImage control
        int nProperty,      // A ZI_ predefined constant
        int nParam          // A parameter matching the type of property to set or retrieve.
        );

        // Get property of a GDImage control
        [DllImport(GDIMAGE, EntryPoint = "ZI_GetProperty")]
        public static extern int GetProperty(
        IntPtr hCtrl,       // The GDImage control
        int nProperty       // A ZI_ predefined constant
        );

        [DllImport(GDIMAGE)]  // Get the Device Context of a GDImage control
        public static extern int ZI_GetDC(
        IntPtr hCtrl        // The GDImage control
        );

        [DllImport(GDIMAGE)]  // Get width and height of a provide bitmap
        public static extern void ZI_GetBitmapSize(
        IntPtr hBitmap,     // Handle to a standard bitmap.
        out int Width,      // Width of the bitmap.
        out int Height      // Height of the bitmap.
        );

        [DllImport(GDIMAGE)]  // Load image from file and return a valid GDIPLUS image handle
        public static extern int zLoadImageFromFile(
        string zFullName,   // Full path name to any of the supported graphic format.
        out int imgW,       // Return the image width.
        out int imgH,       // Return the image height.
        int Orientation     // Orientation to create the memory image.
        );

        [DllImport(GDIMAGE)]  // Save image to file using a valid GDIPLUS image handle.
        public static extern int zSaveImageToFile(
        string zFullName,   // Full path name destination.
        int Img,            // A valid GDIPLUS handle.
        int Quality         // Quality applies to the JPEG format only. 
        );

        [DllImport(GDIMAGE)]  // Save image to file using a valid GDIPLUS image handle.
        public static extern int ZD_DrawTextToCtrl(
        IntPtr hCtrl,       // The GDImage control
        string zUseTex,     // The text to display.
        int x,              // Top left X coordinate.
        int y,              // Top left Y coordinate.
        uint ColrARGB,      // The ARGB color to use.
        string zUseFont,    // The "Tue Type Font" name to use.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -