如何提取出DLL中的位图资源呢?(简单问题)(20分)

  • 主题发起人 主题发起人 mylem
  • 开始时间 开始时间
M

mylem

Unregistered / Unconfirmed
GUEST, unregistred user!
谁能帮我完成如下的代码:<br>说明:bmp.dll是包含位图的dll,'WB'是dll中的位图的名称<br>由于loadimage函数得到的是位图的句柄,但我要的是位图本身的数据<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>VAR<br>HbmpLib:THandle;<br>tmpbmp:TBitmap;<br>begin<br>HbmpLib:=LoadLibrary('bmp.dll');<br>tmpbmp:=Tbitmap.Create;<br>loadimage(Hbmplib,'WB',IMAGE_BITMAP,0,0,LR_DEFAULTCOLOR);<br><br>///////在下面该写什么把把位图调入一个imagelist中呢<br><br><br><br>////////////////////<br><br>end;
 
下面的代码保存到image中,imagelist用imagelist.add......<br>var rshandle,h:THandle;<br>&nbsp; &nbsp; bmp:TBitmap;<br>&nbsp; &nbsp; S:TMemoryStream;<br>// &nbsp; &nbsp;s1:TFileStream;<br>&nbsp; &nbsp; i:integer;<br>&nbsp; &nbsp;JPEGImg: TJPEGImage;<br>begin<br>&nbsp; h:=LoadLibrary('FormImages');<br>&nbsp; if h&lt;=0 then<br>&nbsp; &nbsp; showMessage('Load Dll Error')<br>&nbsp; else begin<br>&nbsp; S:=TMemoryStream.Create;<br>&nbsp; s.Clear;<br>&nbsp; rshandle:=FindResource(h,pchar('My'),PChar('UNKNOW'));<br>&nbsp; i:=LoadResource(h,rshandle);<br>&nbsp; s.WriteBuffer(ptr(i)^,SizeOfResource(h,rshandle));<br>&nbsp; s.Position:=0;<br>&nbsp; JPEGImg:=TJPEGImage.Create;<br>&nbsp; JPEGImg.LoadFromStream(S);<br>&nbsp; Image1.Picture.Assign(JPEGImg);<br><br><br>&nbsp; end;<br>&nbsp; freeLibrary(h);<br>&nbsp; s.Free;<br>&nbsp; jpegimg.free;<br>end;<br>
 
var<br>&nbsp; BitMap1: TBitMap;<br>begin<br>&nbsp; BitMap1 := TBitMap.Create;<br>&nbsp; Image1.visible := false;<br>&nbsp; if hReportLib &gt; 0 then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; try<br>//LibraryHandle:= LoadLibrary(pchar('资源.dll'));<br>&nbsp; &nbsp; &nbsp; &nbsp; BitMap1.LoadFromResourceName(LibraryHandle, 'bmp1');<br>&nbsp; &nbsp; &nbsp; &nbsp; Image1.Width := BitMap1.width + 2;<br>&nbsp; &nbsp; &nbsp; &nbsp; Image1.Height := BitMap1.Height + 2;<br>&nbsp; &nbsp; &nbsp; &nbsp; Image1.Canvas.Draw(1, 1, BitMap1);<br>&nbsp; &nbsp; &nbsp; &nbsp; Image1.Visible := true;<br>&nbsp; &nbsp; &nbsp; finally<br>&nbsp; &nbsp; &nbsp; &nbsp; freeandnil(BitMap1);<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>
 
谢谢两位,不过我希望把位图放入imagelist中,不是image控件中,该怎么实现呢?
 
后退
顶部