找回密码
 加入
搜索
查看: 3669|回复: 5

[图形处理] 图片背景色透明问题(已解决)

  [复制链接]
发表于 2011-12-2 11:42:57 | 显示全部楼层 |阅读模式
本帖最后由 shenrenba 于 2011-12-3 09:19 编辑

如何使下面的BMP图片背景色透明? (不容许上传BMP文件 ,打包了)
注:背景色不是白色 是0XFF00FF  白色的用SetBitmap 可以做到透明

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2011-12-2 12:59:29 | 显示全部楼层
TransparentBlt用这个透明贴图
 楼主| 发表于 2011-12-2 13:39:12 | 显示全部楼层
回复 2# seniors

那看看我这代码 一直出错
#include <GDIPlus.au3>

#include <WinAPI.au3>


_GDIPlus_Startup()

$hBitmap = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\player_skin.bmp")

$hclone = _GDIPlus_BitmapCloneArea($hBitmap, 0, 0, _GDIPlus_ImageGetWidth($hBitmap), _GDIPlus_ImageGetHeight($hBitmap))

$hGraphic = _GDIPlus_ImageGetGraphicsContext($hclone)
;$hGraphic1 = _GDIPlus_GraphicsCreateFromHDC(_WinAPI_CreateCompatibleDC(0))

$hHBITMAP1 = _WinAPI_CreateBitmap(_GDIPlus_ImageGetWidth($hBitmap), _GDIPlus_ImageGetHeight($hBitmap), 1, 32)
$hCDC = _WinAPI_CreateCompatibleDC(0)
$hOld = _WinAPI_SelectObject($hCDC, $hHBITMAP1)
$hGraphic1 = _GDIPlus_GraphicsCreateFromHDC($hCDC)
_GDIPlus_GraphicsClear($hGraphic1, 0x00000000)

DllCall("msimg32.dll", "BOOL", "TransparentBlt", "hwnd", $hGraphic1, "int", 0, "int", 0, "int", _GDIPlus_ImageGetWidth($hBitmap), "int", _GDIPlus_ImageGetHeight($hBitmap), _
                "hwnd", $hGraphic, "int", 0, "int", 0, "int", _GDIPlus_ImageGetWidth($hBitmap), "int", _GDIPlus_ImageGetHeight($hBitmap), "UINT", "RGB(255,0,255)")
;~ DllCall("gdi32.dll", "BOOL", "BitBlt", "hwnd", $hGraphic2, "int", 0, "int", 0, "int", _GDIPlus_ImageGetWidth($hBitmap), "int", _GDIPlus_ImageGetHeight($hBitmap), _
;~                 "hwnd", $hGraphic1, "int", 0, "int", 0, "dword", "SRCCOPY")
_GDIPlus_ImageSaveToFile($hHBITMAP1, @ScriptDir & "\111.bmp")
_GDIPlus_GraphicsDispose($hGraphic)

_GDIPlus_GraphicsDispose($hGraphic1)
_GDIPlus_ImageDispose($hclone)
_WinAPI_DeleteObject($hBitmap)

_GDIPlus_Shutdown()
发表于 2011-12-2 15:50:13 | 显示全部楼层
本帖最后由 seniors 于 2011-12-2 16:20 编辑

#include <GDIPlus.au3>
#include <APIConstants.au3>
#include <WinAPIEx.au3>


_GDIPlus_Startup()
$hImage = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\player_skin.bmp")
$hdestDC = _WinAPI_GetDC(0)
$hMemDC = _WinAPI_CreateCompatibleDC($hdestDC)
$hBitmap = _WinAPI_CreateCompatibleBitmap($hdestDC, _GDIPlus_ImageGetWidth($hImage), _GDIPlus_ImageGetHeight($hImage))

$hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
$hGraphic = _GDIPlus_GraphicsCreateFromHDC($hMemDC)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 0, 0, _GDIPlus_ImageGetWidth($hImage), _GDIPlus_ImageGetHeight($hImage))_GDIPlus_GraphicsDispose($hGraphic)

_WinAPI_TransparentBlt($hdestDC, 0, 0, _GDIPlus_ImageGetWidth($hImage), _GDIPlus_ImageGetHeight($hImage), $hMemDC, 0, 0, _GDIPlus_ImageGetWidth($hImage), _GDIPlus_ImageGetHeight($hImage), 0XFF00FF)
;_WinAPI_BitBlt($hScrDC,0,0,_GDIPlus_ImageGetWidth($hImage), _GDIPlus_ImageGetHeight($hImage), $hMemDC,0,0, $SRCCOPY)


_WinAPI_ReleaseDC(0, $hdestDC)
_WinAPI_SelectObject($hMemDC, $hOld)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_DeleteDC($hMemDC)

_GDIPlus_BitmapDispose($hImage)
_GDIPlus_Shutdown()

_GDIPlus_GraphicsDrawImageRect和_GDIPlus_GraphicsDrawImage怪事,会不一样

评分

参与人数 2金钱 +60 贡献 +5 收起 理由
shenrenba + 30 + 5
afan + 30

查看全部评分

发表于 2013-3-12 16:44:49 | 显示全部楼层
支持樓主分享,謝謝樓主
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-17 12:20 , Processed in 0.082561 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表