Option ExplicitDim Tex As POINTAPI
Dim Dis As Long
Dim Pot1 As POINTAPI
Dim pRot As Double
Dim oRot As DoubleConst Ken = 0.0005
Const PI = 3.1415926
Const Scal = 0.92
Const ScaX = 13
Const ScaY = 13
Private Sub Emendation_Click()
Dim BColor As Long
Dim i As Long, j As Long
Tex.X = Pic1.Width / 2
Tex.Y = Pic1.Height / 2
For j = 1 To Pic1.Height
For i = 1 To Pic1.Width
BColor = GetPixel(Pic1.hdc, i, j)
pRot = (i - Tex.X) ^ 2 + (j - Tex.Y) ^ 2
If i <> Tex.X Then
oRot = Atn((j - Tex.Y) / (i - Tex.X))
Else
If j <= Tex.Y Then
oRot = -PI / 2
Else
oRot = PI / 2
End If
End If
If i >= Tex.X Then
Pot1.X = Scal * (i + Ken * pRot * Cos(oRot)) + ScaX
Pot1.Y = Scal * (j + Ken * pRot * Sin(oRot)) + ScaY
SetPixel Pic2.hdc, Pot1.X + 1, Pot1.Y + 1, BColor
SetPixel Pic2.hdc, Pot1.X, Pot1.Y + 1, BColor
SetPixel Pic2.hdc, Pot1.X + 1, Pot1.Y, BColor
SetPixel Pic2.hdc, Pot1.X, Pot1.Y, BColor
SetPixel Pic2.hdc, Pot1.X - 1, Pot1.Y, BColor
SetPixel Pic2.hdc, Pot1.X, Pot1.Y - 1, BColor
SetPixel Pic2.hdc, Pot1.X - 1, Pot1.Y - 1, BColor
Else
Pot1.X = Scal * (i - Ken * pRot * Cos(oRot)) + ScaX
Pot1.Y = Scal * (j - Ken * pRot * Sin(oRot)) + ScaY
SetPixel Pic2.hdc, Pot1.X + 1, Pot1.Y + 1, BColor
SetPixel Pic2.hdc, Pot1.X, Pot1.Y + 1, BColor
SetPixel Pic2.hdc, Pot1.X + 1, Pot1.Y, BColor
SetPixel Pic2.hdc, Pot1.X, Pot1.Y, BColor
SetPixel Pic2.hdc, Pot1.X - 1, Pot1.Y, BColor
SetPixel Pic2.hdc, Pot1.X, Pot1.Y - 1, BColor
SetPixel Pic2.hdc, Pot1.X - 1, Pot1.Y - 1, BColor
End If
Next
NextPic2.Picture = Pic2.ImageEnd Sub
Dim Dis As Long
Dim Pot1 As POINTAPI
Dim pRot As Double
Dim oRot As DoubleConst Ken = 0.0005
Const PI = 3.1415926
Const Scal = 0.92
Const ScaX = 13
Const ScaY = 13
Private Sub Emendation_Click()
Dim BColor As Long
Dim i As Long, j As Long
Tex.X = Pic1.Width / 2
Tex.Y = Pic1.Height / 2
For j = 1 To Pic1.Height
For i = 1 To Pic1.Width
BColor = GetPixel(Pic1.hdc, i, j)
pRot = (i - Tex.X) ^ 2 + (j - Tex.Y) ^ 2
If i <> Tex.X Then
oRot = Atn((j - Tex.Y) / (i - Tex.X))
Else
If j <= Tex.Y Then
oRot = -PI / 2
Else
oRot = PI / 2
End If
End If
If i >= Tex.X Then
Pot1.X = Scal * (i + Ken * pRot * Cos(oRot)) + ScaX
Pot1.Y = Scal * (j + Ken * pRot * Sin(oRot)) + ScaY
SetPixel Pic2.hdc, Pot1.X + 1, Pot1.Y + 1, BColor
SetPixel Pic2.hdc, Pot1.X, Pot1.Y + 1, BColor
SetPixel Pic2.hdc, Pot1.X + 1, Pot1.Y, BColor
SetPixel Pic2.hdc, Pot1.X, Pot1.Y, BColor
SetPixel Pic2.hdc, Pot1.X - 1, Pot1.Y, BColor
SetPixel Pic2.hdc, Pot1.X, Pot1.Y - 1, BColor
SetPixel Pic2.hdc, Pot1.X - 1, Pot1.Y - 1, BColor
Else
Pot1.X = Scal * (i - Ken * pRot * Cos(oRot)) + ScaX
Pot1.Y = Scal * (j - Ken * pRot * Sin(oRot)) + ScaY
SetPixel Pic2.hdc, Pot1.X + 1, Pot1.Y + 1, BColor
SetPixel Pic2.hdc, Pot1.X, Pot1.Y + 1, BColor
SetPixel Pic2.hdc, Pot1.X + 1, Pot1.Y, BColor
SetPixel Pic2.hdc, Pot1.X, Pot1.Y, BColor
SetPixel Pic2.hdc, Pot1.X - 1, Pot1.Y, BColor
SetPixel Pic2.hdc, Pot1.X, Pot1.Y - 1, BColor
SetPixel Pic2.hdc, Pot1.X - 1, Pot1.Y - 1, BColor
End If
Next
NextPic2.Picture = Pic2.ImageEnd Sub
解决方案 »
- [请教]VBA中分数计算的问题?
- 怎么获得其他程序有焦点地控件的句柄?
- VB中如何给autodesk volo view control加载CAD文档
- 如何在VB中调用printscreen,并保存当前屏幕为图片文件
- 如何确定已读取的象素在Picture中的位置(200分)
- 这个系统提示表示什么呢?
- list和combo
- 大家帮我一下,现在你们怎么访问数据库的?有人说我的数据库访问方法过时。他是什么意思?我用ADO控件.
- 怎样从资源文件中释放exe文件?
- 开发一套软件应该收多少钱呢?也就是说收费多少的标准是什么?请前辈谈谈自己的经验。
- 怎样不用控件播放MIDI?
- 表与表的联系,在VB中如何实现呢?急,明天中午结账!
高手也各有所长啊。
帮你UP吧。
我上面说的有点不对,我是说想利用 "设备无关位图(DIB)"直接对显存进行读写...
着急呀 ...
用CreateDIBSection创建DIB项,记得保存lplpVoid参数得值,它是DIB位图数据的地址
创建DC并把创建的DIB项选入
把图像Bitblt进来处理方法:
虽然用GetBitmapBits可以得到图像数据
但这样比较慢
由于先前得到了lplpVoid参数得值(DIB位图数据的地址)
可以把一个数组的SAFEARRAY结构的pvData改成lplpVoid参数得值
这样可以减少复制内存的时间方法可参考AdamBear的文章:
http://www.csdn.net/develop/author/netauthor/AdamBear/最关键是这个:http://www.csdn.net/Develop/read_article.asp?id=13066
具体的图像处理程序可参考:
http://www.21code.com/codebase/?pos=down&id=1754
源码类型: VisualBasic源码-图形方面
上传时间: 2001-10-28
下载次数: 101
源码大小: 83 KB 源码评价: 源码简介:快速图形处理程序,有几种常见的处理效果,但是速度都比其他示例快
只比Bitblt慢3倍
比AlphaBlend慢1倍
比GetPixel、SetPixelV算半透明快94倍!处理时间(我的CPU是K6-2 350):
普通透明:105毫秒
Alpha通道透明:185毫秒Bitblt到PictureBox:24毫秒
AlphaBlend:58毫秒
GetPixel、SetPixelV算:10.08秒
程序在http://zyl910vb.51.net/test/里的ZDIBop.rar
(没有源程序,只有exe。因为程序好没有写完)
读取到DIB方法我明白,但怎样按照不规则的顺序写入显寸呢?
谢谢你的回答
?????不明白这是什么意思
先在DIB图片中处理
再用Bitblt到屏幕hDC不行吗?
求教老兄:
恳请回答!
源码类型: VisualBasic源码-图形方面
上传时间: 2001-10-28
下载次数: 101
源码大小: 83 KB 源码评价: 源码简介:快速图形处理程序,有几种常见的处理效果,但是速度都比其他示例快参照它的例子写
她怎么写入dib数组呢?
宽、高、每一行所占字节分别为Width、Height、WidthBytes那么(x,y)的数组下标为(Height-y-1)*WidthBytes+x*3
数据的第一行实际上是图像的最后一行
所以是Height-y-1
要尽量避免 幂运算 以及 浮点乘除比如:
Tex.X = Pic1.Width \ 2
Tex.Y = Pic1.Height \ 2
比
Tex.X = Pic1.Width / 2
Tex.Y = Pic1.Height / 2
快
'ok, this is documented in the original app but i don't
'use that function here :-P
'Original comment as follows:
' ...very useful function of my DIB-Helper class. MapArray fools VB
' making him think that his array (which is not bounded, in fact)
' is mapped to particular space in memory (DIB bits in our case).
' it returns byte-width of one line of pixels in DIB
'so what it does is return a linear array whit the color information of each pixel
'but be careful!!! each pixel is converted to three (RGB) bytes and the DIB is upside-down
'and what we have in memory is the last pixel at the beggining and in the format BGR sa.cDims = 1
sa.cbElements = 1
sa.pvData = lpRGB
sa.CE0 = bmH.biSizeImage
CopyMemory saPtr, ByVal VarPtr(a) + 8, 4
CopyMemory ByVal saPtr, VarPtr(sa), 4
'☆☆这就是WidthBytes,作为函数的返回值☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
MapArray = bmH.biSizeImage \ bmH.biHeight
End Function