alphablend

时间:2024-06-09 02:31:54编辑:花茶君

VB 求图片透明的处理!!!!!!!

不知道你说的究竟是怎样的透明

AlphaBlend 的功能就是两幅图片的alpha混合
能不能说的再具体点

2张图片不一样大,并没有关系 AlphaBlend 可以分别指定源图象和目标图象大小
只要将 2个PICTURE的autoredraw属性设为true ,即使图片框不可见

50%透明化也可以实现的

Private Const SRCCOPY = &HCC0020
Private Declare Function AlphaBlend Lib "msimg32.dll" (ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal hdc As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal lInt As Long, ByVal BLENDFUNCT As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

Private Sub Form_Load()
Picture1.AutoSize = True
Picture1.AutoRedraw = True
Picture1.Visible = False
Picture2.AutoSize = True
Picture2.AutoRedraw = True
Picture2.Visible = False
End Sub

Private Sub Command1_Click()
Picture1.Picture = LoadPicture("c:\1.bmp")
Picture2.Picture = LoadPicture("c:\2.bmp")

AlphaBlend Picture1.hdc, 10, 10, 100, 100, Picture1.hdc, 20, 20, 100, 100, &H10000 * 128
BitBlt Me.hdc, 0, 0, 300, 300, Picture1.hdc, 0, 0, SRCCOPY

End Sub


Picture1,Picture2都是不可见的
完成混合后,将混合效果复制到了窗体

AlphaBlend 的 混合度参数 BLENDFUNCT
在VB里使用时 格式为 混合度(0-255)* &H10000


我发现 WINAPI 里面的 alphablend()函数不能用啊

查了一下MSDN,但是也不知道问题到底是在哪里

The AlphaBlend function displays bitmaps that have transparent or semitransparent pixels.

BOOL AlphaBlend(
HDC 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
HDC 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
);

Requirements
Windows NT/2000/XP: Included in Windows 2000 and later.
Windows 95/98/Me: Included in Windows 98 and later.
Header: Declared in Wingdi.h; include Windows.h.
Library: Included as a resource in Msimg32.dll.

看Requirements
应该#include Windows.h就可以了。因为你这个是编译错。


vb编程中如何实现让两张图片交替显示

picture可以看做是一个存放图片的容器。想实现您的要求,只需在窗体中加入
两个image控件,分别加入2张图片,再加一个Timer.

窗体的命令是如下:
Private Sub Form_Load()
Timer1.Interval = 1000
Image1.Visible = False
Image2.Visible = True
End Sub
钟表的命令如下:
Private Sub Timer1_Timer()
Image1.Visible = Not Image1.Visible
Image2.Visible = Not Image2.Visible
End Sub

我是用VB试过了的,可以实现您的要求。


wps如何设置单击两张图片同时位移然后重叠在一起

1第一步:选中图片鼠标右键,选择【设置对象格式】。
2第二步:在跳出的对话框中选择【版式】,在环绕方向这一栏选中【四周型】。
3第三步:单击【确定】以后,这张图片就可以随意的挪动了,另一张图片也用同一种方法进行设置,都设置好了以后,我们就可以把一张图片叠放到另一张图片上面了。
4第四步:如果想让另一张图片在上方,单击另一张图片,鼠标右键,选择【叠放次序】,选择【置于顶层】,此时另一张图片就置于原图片的上面了。
5第五步:按照位置叠放好了以后,此时我们需要将其进行组合到一起,这样就能防止随意移动引起的乱串现象。方法是同时将这两张图片选中,单击鼠标右键,选择【组合】下面的【组合】,此时两张图片就变为一张图片了。
6第六步:如果觉得图片的位置不合适,我们可以将其取消组合,重新调整以后再组合到一起,方法:选中图片鼠标右键,选择【组合】里面的【取消组合】,此时我们就可以重新调整。


VB中怎么使Image或PictureBox控件中图片半透明

示例:背景为纯白色执行后:代码:'========================================'声明作用:透明化PictureBox,注意设置其背景颜色为纯白'========================================Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As LongPrivate Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As LongPrivate Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As LongPrivate Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As LongPrivate Declare Sub ReleaseCapture Lib "user32" ()Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As LongPrivate Const RGN_DIFF = 4Dim CurRgn As Long, TempRgn As Long ' Region variables '========================================'函数名称:ShapeMe'函数作用:透明化PictureBox背景'========================================Public Sub ShapeMe(Color As Long, HorizontalScan As Boolean, Optional Name1 As Form = Nothing, Optional Name2 As PictureBox = Nothing) Dim X As Integer, Y As Integer 'points on form Dim dblHeight As Double, dblWidth As Double 'height and width of object Dim lngHDC As Long 'the hDC property of the object Dim booMiddleOfSet As Boolean 'used during the gathering of transparent points Dim colPoints As Collection 'this will hold all usrPoints Set colPoints = New Collection Dim Z As Variant 'used during iteration through collection Dim dblTransY As Double 'these 3 variables hold each point that will be made transparent Dim dblTransStartX As Double Dim dblTransEndX As Double Dim Name As Object 'will hold the name of the object. Late-bound and slower, but allows different types (in this case Form or PictureBox) 'check out the name or names passed into the subroutine If Name1 Is Nothing Xor Name2 Is Nothing Then 'we know there is a name in one of them If Name1 Is Nothing Then 'set the name Set Name = Picture1 Else Set Name = Picture1 End If Else 'both or none hold valid names MsgBox "Must pass in the name of either a Form OR a PictureBox. TransForm received NONE or BOTH. Function failed.", vbOKOnly, "ShapeMe Subroutine" Exit Sub End If 'initialization With Name .AutoRedraw = True 'object must have this setting .ScaleMode = 3 'object must have this setting lngHDC = .hdc 'faster to use a variable; VB help recommends using the property, but I didn't encounter any problems If HorizontalScan = True Then 'look for lines of transparency horizontally dblHeight = .ScaleHeight 'faster to use a variable dblWidth = .ScaleWidth 'faster to use a variable Else 'look vertically (note that the names "dblHeight" and "dblWidth" are non-sensical now, but this was an easy way to do this dblHeight = .ScaleWidth 'faster to use a variable dblWidth = .ScaleHeight 'faster to use a variable End If 'HorizontalScan = True End With booMiddleOfSet = False 'gather all points that need to be made transparent For Y = 0 To dblHeight ' Go through each column of pixels on form dblTransY = Y For X = 0 To dblWidth ' Go through each line of pixels on form 'note that using GetPixel appears to be faster than using VB's Point If TypeOf Name Is Form Then 'check to see if this is a form and use GetPixel function which is a little faster If GetPixel(lngHDC, X, Y) = Color Then ' If the pixel's color is the transparency color, record it If booMiddleOfSet = False Then dblTransStartX = X dblTransEndX = X booMiddleOfSet = True Else dblTransEndX = X End If 'booMiddleOfSet = False Else If booMiddleOfSet Then colPoints.Add Array(dblTransY, dblTransStartX, dblTransEndX) booMiddleOfSet = False End If 'booMiddleOfSet = True End If 'GetPixel(lngHDC, X, Y) = Color ElseIf TypeOf Name Is PictureBox Then 'if a PictureBox then use Point; a little slower but works when GetPixel doesn't If Name.Point(X, Y) = Color Then If booMiddleOfSet = False Then dblTransStartX = X dblTransEndX = X booMiddleOfSet = True Else dblTransEndX = X End If 'booMiddleOfSet = False Else If booMiddleOfSet Then colPoints.Add Array(dblTransY, dblTransStartX, dblTransEndX) booMiddleOfSet = False End If 'booMiddleOfSet = True End If 'Name.Point(X, Y) = Color End If 'TypeOf Name Is Form Next X Next Y CurRgn = CreateRectRgn(0, 0, dblWidth, dblHeight) ' Create base region which is the current whole window For Each Z In colPoints 'now make it transparent TempRgn = CreateRectRgn(Z(1), Z(0), Z(2) + 1, Z(0) + 1) ' Create a temporary pixel region for this pixel CombineRgn CurRgn, CurRgn, TempRgn, RGN_DIFF ' Combine temp pixel region with base region using RGN_DIFF to extract the pixel and make it transparent DeleteObject (TempRgn) ' Delete the temporary region and free resources Next SetWindowRgn Name.hwnd, CurRgn, True ' Finally set the windows region to the final product 'I do not use DeleteObject on the CurRgn, going with the advice in Dan Appleman's book: 'once set to a window using SetWindowRgn, do not delete the region. Set colPoints = Nothing End SubPrivate Sub Command1_Click()Picture1.BackColor = RGB(0, 0, 0) '需要透明的颜色(纯白色)ShapeMe RGB(255, 255, 255), True, , Picture1 '透明底色End Sub


msimg32.lib 是什么作用

搞了将近一个礼拜的读别人的源码,最后一直没能编译成功,原因是老是弹出个关于AlphaBlend的错误,后来仔细检查一下,才知道必须添加个msimg32.lib 的库的支持,将基添加入工程,一直没搞明白的错误居然轻松搞定,为庆祝一下,故将AlphaBlend的作用总结在自己的博客里面. 『Alpha-Blending』 所谓Alpha-Blending,其实就是按照“Alpha”混合向量的值来混合源像素和目标像素,一般用来处理半透明效果。 Alpha-Blending 技术并简单介绍 Alpha-Blending 技术的具体算法。 所谓Alpha-Blending,其实就是按照“Alpha”混合向量的值来混合源像素和目标像素。为了便于理解,我们就从两个像素间的 Alpha-Blending 过程谈起吧。 第一步,先把源像素和目标像素的 RGB 三个颜色分量分离,然后把源像素的三个颜色分量分别乘上 Alpha 的值,并把目标像素的三个颜色分量分别乘上 Alpha 的反值,接下来把结果按对应颜色分量相加,再对最后求得的每个分量结果除以 Alpha 的最大值(通常这一步都是用移位来完成,这亦是 Alpha 的最大值为何总是二的幂的原因),最后把三个颜色分量重新合成为一个像素输出。 在这个过程中,为了分离像素中的 RGB 三个颜色分量,我们一般会使用掩膜的方法。至于具体的三个掩膜值:RMask、GMask 和BMask,可以从 DirectDraw 中的DDPixelFormat 返回得到(当然,你也可以根据自己的需要做各种灵活处理)。 在下面给出的说明性例程中,我们假设 RMask、GMask 和BMask 已经存放的是 RGB 三个颜色分量的位掩膜值,Alpha 的最大值为 256,而 source 和dest 是指向源像素和目标像素的指针。 int ialpha = 256 - *alpha; // Alpha 的反值 *dest = (RMask & (((*source & RMask) * *alpha + (*dest & RMask) * ialpha) >>8))


无法定位程序输入点ALPHABLEND TRANSPARENTBLT于动态链接库MSIMG32。DLL上,当时你遇到此问题是怎么解决的

什么是动态链接库:英文缩写为DLL,它并不是可执行的文件,它是能向多个程序提供公用代码函数和数据的封装库,程序所需要的一些函数和数据被事先封装在DLL文件中,当程序运行时可以主程序需要调用这些DLL动态链接库。

  无法定位程序输入点 于动态链接库上的原因:

  1.用户误操作不小心将程序安装目录中的动态链接库DLL文件删除,导致程序启动时无法找到必要的文件而报错(这种情况并不是普遍存在的,但也是原因之一)。

  2.电脑感染木马病毒,虽然如今大多数杀毒软件已经趋于人性化,一旦发现某些木马病毒绑定系统程序,还是有不少杀毒软件采用一刀切的方式,直接将这些被恶意绑架的系统程序删除(其中就可能包含DLL动态链接库文件),导致系统或应用程序缺少了必要的DLL动态链接库,从而出现“无法定位程序输入点 于动态链接库上”的问题的(这种情况较为普遍,多数网友都是此原因造成的)。

  3.在软件或游戏在线更新时,本该被正常写入或覆盖的DLL动态链接库文件因为意外的断电、重启、写入错误等原因没有下载更新成功,导致软件或游戏在运行过程中缺少必要的DLL动态链接库文件而报错。

  无法定位程序输入点 于动态链接库上的解决办法:

  步骤一:下载安装主流杀毒软件(卡巴斯基、金山毒霸、360安全卫士、瑞星等等),更新病毒库之后全盘杀毒。

  步骤二:找出提示“无法定位程序输入点 于动态链接库xxxx.dll上”错误的信息,将系统提示缺少的xxxx.dll记录下来。

  步骤三:百度搜索您已经记录下来的xxxx.dll信息,在百度搜索中输入xxxx.dll(加上DLL后缀),尝试通过网络下载 xxxx.dll(目前大多数系统动态链接库DLL文件都可以通过网络下载到),将下载到得DLL保存到U盘或指定文件目录内,假如是系统程序 (如:iexplore.exe、系统驱动程序加载、media play播放器等)报错,在重启电脑按下F8键,进入系统安全模式,将下载到得DLL文件复制到C盘中windows目录下的System32文件夹中,然后再重新启动,便可以解决此问题;如果是游戏程序缺少DLL,下载之后需要将DLL复制到该游戏目录下的指定位置(由于游戏分类众多,所需DLL和位置各有不同,小编无法详细说明,这需要您在实践中摸索)。

  尝试三个步骤都无法解决无法定位程序输入点 于动态链接库上的问题,您应该考虑重装系统、软件或游戏了。


上一篇:股指期货的手续费

下一篇:微笑说离开