请教如何把32位或者16位bmp转换为24位bmp,(已解决)
本帖最后由 ebhb 于 2012-6-25 21:14 编辑做一个验证码识别试验,用到大漠插件,结果只支持24位bmp图片 用 _GDIPlus_BitmapCloneArea() 试试 用了以下转换代码,转出来还是32位图形,郁闷。
#include <GDIPlus.au3>
jb("11.bmp","15.bmp")
Func JB($f1,$f2)
Local $hImage, $CLSID
_GDIPlus_StartUp()
$hImage = _GDIPlus_ImageLoadFromFile($f1)
$CLSID = _GDIPlus_EncodersGetCLSID("BMP")
_GDIPlus_ImageSaveToFileEx($hImage,$f2, $CLSID)
_GDIPlus_ShutDown()
EndFunc 试了_GDIPlus_BitmapCloneArea()转出来还是32位 #include <GDIPlus.au3>
jb("11.bmp","15.bmp")
Func JB($f1,$f2)
Local $hImage, $CLSID
_GDIPlus_StartUp()
$hImage = _GDIPlus_ImageLoadFromFile($f1)
; $hImage = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap)
; Create 24 bit bitmap clone
$iX = _GDIPlus_ImageGetWidth ($hImage)
$iY = _GDIPlus_ImageGetHeight ($hImage)
$hClone = _GDIPlus_BitmapCloneArea ($hImage, 0, 0, $iX, $iY, $GDIP_PXF16GRAYSCALE)
;$CLSID = _GDIPlus_EncodersGetCLSID("BMP")
_GDIPlus_ImageSaveToFile($hClone,$f2)
_GDIPlus_ShutDown()
EndFunc
#include <GDIPlus.au3>
#include <GDIP.au3>
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\bmp32.bmp")
$iWidth = _GDIPlus_ImageGetWidth($hImage)
$iHeight = _GDIPlus_ImageGetHeight($hImage)
$tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iWidth, $iHeight, $GDIP_ILMREAD, $GDIP_PXF24RGB)
$iStride = DllStructGetData($tBitmapData, "Stride")
$iScan0 = DllStructGetData($tBitmapData, "Scan0")
$hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride, $GDIP_PXF24RGB, $iScan0)
_GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\bmp24.bmp")
_GDIPlus_BitmapUnlockBits($hImage, $tBitmapData)
_GDIPlus_Shutdown()
太奇怪了,宽度或者高度必须和原来的不一样才能转换成24位,不然就是32位。 同时谢谢版主和楼上的朋友。
#include <GDIPlus.au3>
jb("11.bmp","15.bmp")
Func JB($f1,$f2)
Local $hImage, $CLSID
_GDIPlus_StartUp()
$hImage = _GDIPlus_ImageLoadFromFile($f1)
; $hImage = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap)
; Create 24 bit bitmap clone
$iX = _GDIPlus_ImageGetWidth ($hImage)
$iY = _GDIPlus_ImageGetHeight ($hImage)
;MsgBox(0,$iX,$iY)
$hClone = _GDIPlus_BitmapCloneArea ($hImage, 0, 0,$iX, $iY-1, $GDIP_PXF24RGB)
;$CLSID = _GDIPlus_EncodersGetCLSID("BMP")
_GDIPlus_ImageSaveToFile($hClone,$f2)
_GDIPlus_ShutDown()
EndFunc gdip.au3这个文件找不到,没法测试了。 回复 8# ebhb
在汉化版里,改名成了GDIPlusEx.au3,在这里可以下载:http://www.autoitx.com/forum.php?mod=viewthread&tid=14279&highlight=gdiplusEx 回复 2# afan
a 大厉害 我用着挺好
页:
[1]