找回密码
 加入
搜索
查看: 8492|回复: 16

[图形处理] 请教如何用resources这个UDF将包里的图片内置进程序

 火.. [复制链接]
发表于 2010-7-20 22:06:51 | 显示全部楼层 |阅读模式
我把文件打包,我是下的别人的一个程序进行测试下resources这个UDF的

试了好久没成功,现将程序打包  求大家帮忙!

本帖子中包含更多资源

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

×
发表于 2010-7-21 06:42:50 | 显示全部楼层
官网不是有这个函数库的示例吗
发表于 2010-7-21 08:13:01 | 显示全部楼层
resource的资源需要编译后才能显现出效果。
 楼主| 发表于 2010-7-21 11:45:00 | 显示全部楼层
回复 2# netegg


可我怎么修改就是没效果,只能来请各位帮帮忙 !
发表于 2010-7-21 11:46:38 | 显示全部楼层
我也没仔细研究过
 楼主| 发表于 2010-7-21 14:52:28 | 显示全部楼层
来人帮帮忙捏·~
 楼主| 发表于 2010-7-21 19:27:43 | 显示全部楼层
没人帮我呀!
发表于 2010-7-22 08:04:34 | 显示全部楼层
不明白你怎么这么用...
新版AU3不需要ResHacker.

官方代码:
#AutoIt3Wrapper_Res_File_Add=test_1.txt, rt_rcdata, TEST_TXT_1
#AutoIt3Wrapper_Res_File_Add=image1.bmp, rt_bitmap, TEST_BMP_1
#AutoIt3Wrapper_Res_File_Add=image2.bmp, rt_bitmap, TEST_BMP_2
#AutoIt3Wrapper_Res_File_Add=image3.jpg, rt_rcdata, TEST_JPG_3
;~ #AutoIt3Wrapper_Res_File_Add=binary1.dat, rt_rcdata, TEST_BIN_1
;~ #AutoIt3Wrapper_Res_File_Add=C:\WINDOWS\Media\tada.wav, sound, TEST_WAV_1

#include "resources.au3"
 
$gui = GUICreate("Data from resources example",820,400)
$pic1 = GUICtrlCreatePic("",0,0,400,300)
$pic2 = GUICtrlCreatePic("",400,0,400,150)
$pic3 = GUICtrlCreatePic("",400,150,400,150)
$pic4 = GUICtrlCreatePic("",600,320,400,100)
$label1 = GUICtrlCreateLabel("",20,320,380,100)
$label2 = GUICtrlCreateLabel("",400,320,200,100)
GUISetState(@SW_SHOW)

; get string from resource
$string = _ResourceGetAsString("TEST_TXT_1")
GUICtrlSetData($label1, $string)

; set BMP image to picture control from resource  bitmap
_ResourceSetImageToCtrl($pic1, "TEST_BMP_1", $RT_BITMAP)

; get bitmap from resource (as pointer)
$hBmp = _ResourceGet("TEST_BMP_2", $RT_BITMAP)
; and use it for whatever you like
_SetBitmapToCtrl($pic2, $hBmp)

; set JPG image to picture control from resource
_ResourceSetImageToCtrl($pic3, "TEST_JPG_3")

; set image to picture control from external DLL resource
_ResourceSetImageToCtrl($pic4, "#14355", $RT_BITMAP, @SystemDir & "\shell32.dll")

; get/use picture from resources as hImage type
$size1 = _ResourceGetImageSize("TEST_BMP_1", $RT_BITMAP)
$size2 = _ResourceGetImageSize("TEST_JPG_3")
GUICtrlSetData($label2, $size1 & @CRLF & $size2)

; save binary data or another type (image) from resource to file and get its size in bytes
$size1 = _ResourceSaveToFile(@ScriptDir & "\binary_data1.dat", "TEST_BIN_1")
$size2 = _ResourceSaveToFile(@ScriptDir & "\binary_data2.bmp", "TEST_BMP_1", $RT_BITMAP)

; save binary data from resource to file (create not existing directory)
_ResourceSaveToFile("C:\Dir1\SubDir2\binary_data1.dat", "TEST_BIN_1", $RT_RCDATA, 0, 1)
_ResourceSaveToFile("C:\Dir1\SubDir2\binary_data2.bmp", "TEST_BMP_1", $RT_BITMAP, 0, 1)

; play WAV from resource (sync/async)
_ResourcePlaySound("TEST_WAV_1")
_ResourcePlaySound("TEST_WAV_1", $SND_ASYNC)

While 1
    If GUIGetMsg() = -3 Then Exit
WEnd

Func _ResourceGetImageSize($ResName, $ResType = 10) ; $RT_RCDATA = 10
        ; get/use picture from resources as hImage type
        $hImage = _ResourceGetAsImage($ResName, $ResType)
        _GDIPlus_Startup()
        $width =  _GDIPlus_ImageGetWidth ($hImage)
        $height = _GDIPlus_ImageGetHeight($hImage)
        _GDIPlus_Shutdown()
        
        Return "Size of " & $ResName & " is: " & $width & "x" & $height
EndFunc
 楼主| 发表于 2010-7-22 10:13:08 | 显示全部楼层
回复 8# republican

请教  你的这个不也是 Resource吗?
那我想把图片内置    用在循环里   怎么实现?
发表于 2010-7-22 11:33:58 | 显示全部楼层
回复 9# zz999

你的使用了ResHacker,不是Resource。

官方示例已经有很明确的用法了,LZ能不能把示例先研究一下?


本帖子中包含更多资源

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

×
 楼主| 发表于 2010-7-22 13:27:11 | 显示全部楼层
回复 10# republican

我知道,但我测试了好几次   就是不显示!
所以来求具体修改方法!
发表于 2010-7-22 16:33:58 | 显示全部楼层
回复 11# zz999

resource_test.au3  集合了全部用法。

我在三楼说了,要编译后才有效果的。
发表于 2010-7-22 16:35:59 | 显示全部楼层
新版AU3不支持这个UDF,此问题无解。这个早在08年底就过时了。
发表于 2010-7-22 19:01:29 | 显示全部楼层
这个我做界面时用过,刚刚测试了下,新版au3同样编译正常
有空看看~
发表于 2010-7-22 20:28:19 | 显示全部楼层
回复 13# 78391493

3.3.6.1 也是可以用的。
编译我附件的resource_test.au3试试。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-10 09:26 , Processed in 0.126977 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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