找回密码
 加入
搜索
查看: 2475|回复: 2

[图形处理] 请问如何获取图片的各种属性

[复制链接]
发表于 2010-2-17 20:12:24 | 显示全部楼层 |阅读模式
请教下如何获取图片的分辨率和颜色深度。
如:1024x768 32bit
感谢回答!
发表于 2010-2-18 00:35:38 | 显示全部楼层
$hFile = FileOpen("0001.jpg", 16)
$bData = FileRead($hFile, 1024)
FileClose($hFile)

$tagJPEG = "byte Header[6];char JFIF[5];byte Version[2];byte DensityUnits;byte XPixel[2];byte YPixel[2];ubyte XZoomPixel;ubyte YZooomPixel;byte Signature[2]"

$tBinary = DllStructCreate("byte Binary[1024]")
$pBuffer = DllStructGetPtr($tBinary)
$tBuffer = DllStructCreate($tagJPEG, $pBuffer)
DllStructSetData($tBinary, "Binary", $bData)
$tBuffer1 = $tBuffer

If (DllStructGetData($tBuffer, "Signature") = "0xFFDB") Then
        $pBuffer += DllStructGetSize($tBuffer) + 69 + 67
Else
        $pBuffer += DllStructGetSize($tBuffer) - 2
EndIf

$tBuffer = DllStructCreate("byte Signature[2]", $pBuffer)

If (DllStructGetData($tBuffer, "Signature") = "0xFFFE") Then
        $pBuffer += DllStructGetSize($tBuffer)
        $tBuffer = DllStructCreate("byte CommentBytes[2]", $pBuffer)
        $pBuffer += Number(String(DllStructGetData($tBuffer, "CommentBytes")))
Else
        $pBuffer += DllStructGetSize($tBuffer) - 2
EndIf


$tBuffer = DllStructCreate("byte Signature[2]", $pBuffer)
Switch DllStructGetData($tBuffer, "Signature")
Case ("0xFFC0")
        $pBuffer += 4
Case ("0xFFDB")
        $pBuffer += 67 * 2 + 8
EndSwitch

$tBuffer = DllStructCreate("byte Accuracy;byte Height[2];byte Width[2]", $pBuffer)

$sInfo = ""
$sInfo = "X DPI: " & Number(String(DllStructGetData($tBuffer1, "XPixel"))) & @CRLF
$sInfo &= "Y DPI: " & Number(String(DllStructGetData($tBuffer1, "YPixel"))) & @CRLF
$sInfo &= "Width: " & Number(String(DllStructGetData($tBuffer, "Width"))) & @CRLF
$sInfo &= "Height: " & Number(String(DllStructGetData($tBuffer, "Height"))) & @CRLF
$sInfo &= "Accuracy: " & Number(String(DllStructGetData($tBuffer, "Accuracy"))) & @CRLF

Msgbox(0, "", $sInfo)
 楼主| 发表于 2010-2-18 12:36:33 | 显示全部楼层
非常感谢,我去看看.....
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-16 22:36 , Processed in 0.072799 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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