VB的gdi+相关声明

模块:

Option Explicit

Public Declare Function GdiplusStartup Lib "gdiplus" (token As Long, inputbuf As GdiplusStartupInput, Optional ByVal outputbuf As Long = 0) As GpStatusPublic Declare Function GdiplusShutdown Lib "gdiplus" (ByVal token As Long) As GpStatus

Public Declare Function GdipCreateFromHDC Lib "gdiplus" (ByVal hDC As Long, graphics As Long) As GpStatusPublic Declare Function GdipDeleteGraphics Lib "gdiplus" (ByVal graphics As Long) As GpStatusPublic Declare Function GdipSetSmoothingMode Lib "gdiplus" (ByVal graphics As Long, ByVal SmoothingMd As SmoothingMode) As GpStatusPublic Declare Function GdipSetInterpolationMode Lib "gdiplus" (ByVal graphics As Long, ByVal interpolation As InterpolationMode) As GpStatusPublic Declare Function GdipSetCompositingQuality Lib "gdiplus" (ByVal graphics As Long, ByVal CompositingQlty As CompositingQuality) As GpStatus

Public Declare Function GdipRotateWorldTransform Lib "gdiplus" (ByVal graphics As Long, ByVal angle As Single, ByVal order As MatrixOrder) As GpStatusPublic Declare Function GdipTranslateWorldTransform Lib "gdiplus" (ByVal graphics As Long, ByVal dx As Single, ByVal dy As Single, ByVal order As MatrixOrder) As GpStatus

Public Declare Function GdipLoadImageFromFile Lib "gdiplus" (ByVal filename As Long, Image As Long) As GpStatusPublic Declare Function GdipDisposeImage Lib "gdiplus" (ByVal Image As Long) As GpStatusPublic Declare Function GdipGetImageWidth Lib "gdiplus" (ByVal Image As Long, Width As Long) As GpStatusPublic Declare Function GdipGetImageHeight Lib "gdiplus" (ByVal Image As Long, Height As Long) As GpStatusPublic Declare Function GdipDrawImageRect Lib "gdiplus" (ByVal graphics As Long, ByVal Image As Long, ByVal x As Single, ByVal y As Single, ByVal Width As Single, ByVal Height As Single) As GpStatus

Public Enum MatrixOrder   MatrixOrderPrepend = 0   MatrixOrderAppend = 1End Enum

Public Enum QualityMode   QualityModeInvalid = -1   QualityModeDefault = 0   QualityModeLow = 1   QualityModeHigh = 2End Enum

Public Enum SmoothingMode   SmoothingModeInvalid = QualityModeInvalid   SmoothingModeDefault = QualityModeDefault   SmoothingModeHighSpeed = QualityModeLow   SmoothingModeHighQuality = QualityModeHigh   SmoothingModeNone   SmoothingModeAntiAliasEnd Enum

Public Enum InterpolationMode   InterpolationModeInvalid = QualityModeInvalid   InterpolationModeDefault = QualityModeDefault   InterpolationModeLowQuality = QualityModeLow   InterpolationModeHighQuality = QualityModeHigh   InterpolationModeBilinear   InterpolationModeBicubic   InterpolationModeNearestNeighbor   InterpolationModeHighQualityBilinear   InterpolationModeHighQualityBicubicEnd Enum

Public Enum CompositingQuality   CompositingQualityInvalid = QualityModeInvalid   CompositingQualityDefault = QualityModeDefault   CompositingQualityHighSpeed = QualityModeLow   CompositingQualityHighQuality = QualityModeHigh   CompositingQualityGammaCorrected   CompositingQualityAssumeLinearEnd Enum

Public Type GdiplusStartupInput   GdiplusVersion As Long   DebugEventCallback As Long   SuppressBackgroundThread As Long   SuppressExternalCodecs As LongEnd Type

Public Enum GpStatus   Ok = 0   GenericError = 1   InvalidParameter = 2   OutOfMemory = 3   ObjectBusy = 4   InsufficientBuffer = 5   NotImplemented = 6   Win32Error = 7   WrongState = 8   Aborted = 9   FileNotFound = 10   ValueOverflow = 11   AccessDenied = 12   UnknownImageFormat = 13   FontFamilyNotFound = 14   FontStyleNotFound = 15   NotTrueTypeFont = 16   UnsupportedGdiplusVersion = 17   GdiplusNotInitialized = 18   PropertyNotFound = 19   PropertyNotSupported = 20End Enum

窗体(AutoRedraw=True)Option Explicit

Dim token As LongDim graphics As Long

Dim img As Long, w As Long, h As Long

Private Sub InitGDIPlus()    Dim uInput As GdiplusStartupInput

    uInput.GdiplusVersion = 1    If GdiplusStartup(token, uInput) <> Ok Then        MsgBox "GDI+ 初始化错误。程序即将关闭。", vbCritical, "InitError"        End    End IfEnd Sub

Private Sub TerminateGDIPlus()    GdipDisposeImage img    GdipDeleteGraphics graphics

    GdiplusShutdown tokenEnd Sub

Private Sub Form_Load()    InitGDIPlus

    GdipCreateFromHDC Me.hDC, graphics    ‘GdipSetSmoothingMode graphics, SmoothingModeAntiAlias    ‘GdipSetInterpolationMode graphics, InterpolationModeHighQuality    ‘GdipSetCompositingQuality graphics, CompositingQualityHighQuality

    GdipLoadImageFromFile StrPtr(App.Path & "\1.png"), img    GdipGetImageWidth img, w    GdipGetImageHeight img, h

    Rotate 15, graphics, 200, 200End Sub

Sub Rotate(angle As Single, g As Long, x As Single, y As Integer)    GdipRotateWorldTransform g, angle, MatrixOrderAppend    GdipTranslateWorldTransform g, x, y, MatrixOrderAppend    GdipDrawImageRect g, img, -w, -h / 2, w, hEnd Sub

Private Sub Form_Unload(Cancel As Integer)    TerminateGDIPlusEnd Sub
时间: 2024-11-09 01:43:45

VB的gdi+相关声明的相关文章

C# (GDI+相关) 图像处理(各种旋转、改变大小、柔化、锐化、雾化、底片、浮雕、黑白、滤镜效果)

原文:C# (GDI+相关) 图像处理(各种旋转.改变大小.柔化.锐化.雾化.底片.浮雕.黑白.滤镜效果) C#图像处理   (各种旋转.改变大小.柔化.锐化.雾化.底片.浮雕.黑白.滤镜效果)     一.各种旋转.改变大小   注意:先要添加画图相关的using引用.   //向右旋转图像90°代码如下: private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {   Graphics g

Winform GDI+ 相关资料

在Visual Studio 2010中定义GDI+自定义控件——自定义控件介绍 http://www.cnblogs.com/zhangdong/archive/2010/05/20/1740177.html C#发现之旅第一讲 C#-XML开发C#发现之旅第二讲 C#-XSLT开发C#发现之旅第三讲 使用C#开发基于XSLT的代码生成器C#发现之旅第四讲 Windows图形开发入门C#发现之旅第五讲 图形开发基础篇C#发现之旅第六讲 C#图形开发中级篇C#发现之旅第七讲 C#图形开发高级篇C

Vb.net/VB 声明API函数实现父窗体功能

回顾第一次敲机房收费,自己调用了api函数实现了父窗体及其子窗体最小化的功能,如今再次遇到,自己就在思考,能不能继续使用API函数呢?答案当然是Of Course! 其实仔细看两者并没有多大的区别,先看看在vb.net中如何调用: 首先添加一个类模块,来封装此API函数: <span style="font-size:14px;"> Public Declare Function SetParent Lib "<span style="color:

Vb.net/VB 声明API函数实现父窗口功能

回想第一次敲机房收费.自己调用了api函数实现了父窗口及其子窗口最小化的功能.现在再次遇到,自己就在思考,能不能继续使用API函数呢?答案当然是Of Course! 事实上细致看两者并没有多大的差别.先看看在vb.net中怎样调用: 首先加入一个类模块,来封装此API函数: <span style="font-size:14px;"> Public Declare Function SetParent Lib "<span style="color

Vb.net/VB 声明API功能父窗口功能

回想第一次敲房费,他说自己是api函数实现父窗口及其子窗口最小化的功能.现在再次遇到,自己就在思考,能不能继续使用API函数呢?答案当然是Of Course! 事实上细致看两者并没有多大的差别,先看看在vb.net中怎样调用: 首先加入一个类模块.来封装此API函数: <span style="font-size:14px;"> Public Declare Function SetParent Lib "<span style="color:#f

VB 调用动态链接库

作为一种简单易用的Windows开发环境,Visual Basic从一推出就受到了广大编程人员的欢迎.它使 程序员不必再直接面对纷繁复杂的Windows消息,而可以将精力主要集中在程序功能的实现上,大大提高了编程效率.但凡事有利必有弊. VB中高度的封装和模块化减轻了编程者的负担,同时也使开发人员失去了许多访问低层API函数和直接与Windows交互的机会.因此,相比而言,VB应用程序的执行效率和功能比C/C++或Delphi生成的程序要差.为了解决这个问题,在一个大型的VB开发应用中,直接调用

VB调用API函数

API函数快速入门--怎样在VB中声明和使用API函数-- 一.在VB中声明API函数有两种方法:如果我们只在某个窗体中使用API函数,我们可以在窗体代码的 General部分声明它: 声明的语法是: Private Declare Function ... Private Declare Sub..... 这里必须采用Private声明,因为这个API函数只能被一个窗体内的程序所调用. 如果我们的程序有多个窗体构成,而且我们需要在多个窗体中使用同一个API函数,就需要在模块中 声明了. 先添加

108次练习之堆的声明及实现(二)

昨天写完堆的代码后,今天又敲了一下,顺便用到了函数对象,可以指定生成最小/大堆. (注释就懒得写了,有什么问题可以私下留言,或者看我上篇文章,毕竟本文仅供个人娱乐) /* *文件说明:堆的相关声明及实现(第二遍) *作者:高小调 *日期:2016-12-27 *集成开发环境:Microsoft Visual Studio 2010 */ #include<vector> template<typename T> struct Min{ bool operator()(T left,

用VB.NET(Visual Basic 2010)封装EXCEL VBA为DLL_COM组件(二)

--将EXCEL VBA代码移植到VB.NET .NET是微软公司在2002年推出的全新编程框架,支持多种语言应用程序开发.使用Visual Basic在Microsoft .NET Framework上编程,这就是Visual Basic.NET,简称VB.NET. VB.NET是Microsoft Visual Studio .NET组件中的重要组成部分,是VB6.0的后续版本,VB.NET仍使用VB的基本语法,二者几乎在90%以上保持相似或相同,虽然Excel VBA代码不能完全像移植到V