我們知道在.NET 平臺(tái)下主要是用GDI+來進(jìn)行圖形圖像處理,在效率要求不高的情況下使用GDI+已經(jīng)足夠?qū)崿F(xiàn)各種功能了,但一旦要求效率的情況下,我們可以考慮使用GDI來代替GDI+,網(wǎng)上有人士做過相關(guān)測(cè)試(本人也測(cè)試過),GDI在圖形、圖像繪制方面效率較GDI+有很大提高。下面將自己開發(fā)過程中整理到的NativeGdi32Api類貼出來:
攸縣ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!
- public static class NativeGdi32Api
- {
- [ DllImport("gdi32.dll" )]
- public static extern int SetDIBits (IntPtr hdc, IntPtr hBitmap, int nStartScan , int nNumScans, IntPtr lpBits, IntPtr lpBI , int wUsage);
- [ DllImport("gdi32.dll" )]
- public static extern int SetDIBitsToDevice (IntPtr hdc, int x, int y , int dx, int dy, int SrcX, int SrcY, int Scan , int NumScans, IntPtr Bits, IntPtr BitsInfo , int wUsage);
- [ DllImport("gdi32.dll" )]
- public static extern IntPtr CreateDIBSection (IntPtr hdc, IntPtr pBitmapInfo, int un , IntPtr lplpVoid , IntPtr handle, int dw);
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto )]
- public static extern int SetPixel (IntPtr hdc, int x, int y , int crColor);
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto )]
- public static extern int GetPixel (IntPtr hdc, int x, int y );
- [ DllImport("gdi32.dll" , CharSet= CharSet.Auto )]
- public static extern int CombineRgn (IntPtr dest, IntPtr src1, IntPtr src2 , int flags);
- [ DllImport("gdi32.dll" , CharSet= CharSet.Auto )]
- public static extern IntPtr CreateBrushIndirect (ref LOGBRUSH brush );
- [ DllImport("gdi32.dll" , CharSet= CharSet.Auto )]
- public static extern IntPtr CreateRectRgnIndirect (ref RECTAPI rect );
- [ DllImport("gdi32.dll" , CharSet= CharSet.Auto )]
- public static extern int GetClipBox (IntPtr hDC, ref RECTAPI rectBox);
- [ DllImport("gdi32.dll" , CharSet= CharSet.Auto )]
- public static extern bool PatBlt (IntPtr hDC, int x, int y , int width, int height, uint flags);
- [ DllImport("gdi32.dll" , CharSet= CharSet.Auto )]
- public static extern int SelectClipRgn (IntPtr hDC, IntPtr hRgn);
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto , CallingConvention = CallingConvention .StdCall, SetLastError=true )]
- public static extern IntPtr MoveToEx (IntPtr hDC, int x, int y , ref POINTAPI lpPoint );
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto , CallingConvention = CallingConvention .StdCall, SetLastError=true )]
- public static extern IntPtr LineTo (IntPtr hDC, int x, int y );
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto , CallingConvention = CallingConvention .StdCall, SetLastError=true )]
- public static extern IntPtr CreatePen (int nPenStyle, int nWidth, int crColor );
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto , CallingConvention = CallingConvention .StdCall, SetLastError=true )]
- public static extern int SetBrushOrgEx (IntPtr hDC, int x, int y , ref POINTAPI p );
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto , CallingConvention = CallingConvention .StdCall, SetLastError=true )]
- public static extern IntPtr CreatePatternBrush (IntPtr hBMP);
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto , CallingConvention = CallingConvention .StdCall, SetLastError=true )]
- public static extern int GetTextFace (IntPtr hDC, int nCount, string lpFacename );
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto , CallingConvention = CallingConvention .StdCall, SetLastError=true )]
- public static extern int GetTextMetrics (IntPtr hDC, ref GDITextMetric TextMetric);
- [ DllImport("gdi32.dll" , CharSet = CharSet.Ansi , CallingConvention = CallingConvention .StdCall, SetLastError=true )]
- public static extern IntPtr CreateFontIndirect ([MarshalAs( UnmanagedType.LPStruct )]LogFont LogFont);
- [ DllImport("gdi32.dll" , SetLastError = true, CharSet = CharSet. Auto, CallingConvention = CallingConvention .StdCall)]
- public static extern int BitBlt (IntPtr hDestDC, int x, int y , int nWidth, int nHeight, IntPtr hSrcDC , int xSrc, int ySrc, int dwRop );
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto , CallingConvention = CallingConvention .StdCall, SetLastError=true )]
- public static extern IntPtr CreateSolidBrush (int crColor);
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto , CallingConvention = CallingConvention .StdCall, SetLastError=true )]
- public static extern int Rectangle (IntPtr hDC, int left, int top , int right, int bottom);
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto , CallingConvention = CallingConvention .StdCall, SetLastError=true )]
- public static extern IntPtr CreateHatchBrush (int Style, int crColor);
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto , CallingConvention = CallingConvention .StdCall, SetLastError=true )]
- public static extern IntPtr CreateCompatibleBitmap (IntPtr hDC, int nWidth, int nHeight );
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto , CallingConvention = CallingConvention .StdCall, SetLastError=true )]
- public static extern IntPtr CreateCompatibleDC (IntPtr hDC);
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto , CallingConvention = CallingConvention .StdCall, SetLastError=true )]
- public static extern IntPtr SelectObject (IntPtr hDC, IntPtr hObject);
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto , CallingConvention = CallingConvention .StdCall, SetLastError=true )]
- public static extern IntPtr DeleteObject (IntPtr hObject);
- [ DllImport("gdi32.dll" , SetLastError = true, CharSet = CharSet. Auto, CallingConvention = CallingConvention .StdCall)]
- public static extern int GetTextColor (IntPtr hDC);
- [ DllImport("gdi32.dll" , SetLastError = true, CharSet = CharSet. Auto, CallingConvention = CallingConvention .StdCall)]
- public static extern int SetTextColor (IntPtr hDC, int crColor);
- [ DllImport("gdi32.dll" , SetLastError = true, CharSet = CharSet. Auto, CallingConvention = CallingConvention .StdCall)]
- public static extern int GetBkColor (IntPtr hDC);
- [ DllImport("gdi32.dll" , SetLastError = true, CharSet = CharSet. Auto, CallingConvention = CallingConvention .StdCall)]
- public static extern int GetBkMode (IntPtr hDC);
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto , CallingConvention = CallingConvention .StdCall, SetLastError=true )]
- public static extern IntPtr DeleteDC (IntPtr hDC);
- [ DllImport("gdi32.dll" , SetLastError = true, CharSet = CharSet. Auto, CallingConvention = CallingConvention .StdCall)]
- public static extern int SetBkColor (IntPtr hDC, int crColor);
- [ DllImport("gdi32.dll" , SetLastError = true, CharSet = CharSet. Auto, CallingConvention = CallingConvention .StdCall)]
- public static extern int SetBkMode (IntPtr hDC, int Mode);
- [ DllImport("gdi32.dll" , CharSet = CharSet.Auto , CallingConvention = CallingConvention .StdCall, SetLastError=true )]
- public static extern int GdiFlush ();
- [ DllImport("gdi32.dll" , SetLastError = true, CharSet = CharSet. Ansi, CallingConvention = CallingConvention .StdCall)]
- public static extern int EnumFontFamiliesEx (IntPtr hDC, [MarshalAs(UnmanagedType .LPStruct)] LogFont lf , FONTENUMPROC proc, Int64 LParam, Int64 DW );
- [ DllImport("gdi32.dll" , EntryPoint = "GdiAlphaBlend" )]
- public static extern bool AlphaBlend (
- IntPtr hdcDest , // handle to destination DC
- int nXOriginDest , // x-coord of upper-left corner
- int nYOriginDest , // y-coord of upper-left corner
- int nWidthDest , // destination width
- int nHeightDest , // destination height
- IntPtr hdcSrc , // handle to source DC
- int nXOriginSrc , // x-coord of upper-left corner
- int nYOriginSrc , // y-coord of upper-left corner
- int nWidthSrc , // source width
- int nHeightSrc , // source height
- BLENDFUNCTION blendFunction // alpha-blending function
- );
- }
另外,如果真的是對(duì)效率要求很高的應(yīng)用,還是推薦大家使用OpenGL、DirectX。.NET平臺(tái)下有與之對(duì)應(yīng)的Tao.OpenGL和Managed DirectX。
創(chuàng)新互聯(lián)www.cdcxhl.cn,專業(yè)提供香港、美國云服務(wù)器,動(dòng)態(tài)BGP最優(yōu)骨干路由自動(dòng)選擇,持續(xù)穩(wěn)定高效的網(wǎng)絡(luò)助力業(yè)務(wù)部署。公司持有工信部辦法的idc、isp許可證, 機(jī)房獨(dú)有T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確進(jìn)行流量調(diào)度,確保服務(wù)器高可用性。佳節(jié)活動(dòng)現(xiàn)已開啟,新人活動(dòng)云服務(wù)器買多久送多久。
新聞標(biāo)題:C#使用GDI中的API函數(shù)-創(chuàng)新互聯(lián)
轉(zhuǎn)載源于:http://m.rwnh.cn/article22/dopejc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)、響應(yīng)式網(wǎng)站、App設(shè)計(jì)、網(wǎng)站設(shè)計(jì)公司、靜態(tài)網(wǎng)站、網(wǎng)站導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容