Alexandra
December 5th, 1999, 05:05 AM
Hi!
Does anyone know how to draw a bitmap into a memory?
I am trying to use StdPicture.Render , but I can use only hdc object like picturebox, form , etc, unless I get run-time error "Invalid procedure call or argument (Error 5)".But I need draw the bitmap into a memory and after that I want to do sometning with it( for animation in ActiveX).
Thanks!
Dim hBmps(0 to 5) as Long
private Sub UserControl_ReadProperties(PropBag as PropertyBag)
Dim pic as IPictureDisp
Dim hCdc as Long
Dim hCdcTemp as Long
Dim hBmp as Long
Dim i as integer
...
namebmp = PropBag.ReadProperty("namebmp")
...
set pic = LoadPicture(namebmp)
hCdc = CreateCompatibleDC(UserControl.hdc)
hCdcTemp = CreateCompatibleDC(UserControl.hdc)
hBmp = CreateCompatibleBitmap(UserControl.hdc, bmp_width, bmp_height)
SelectObject hCdc, hBmp
pic.Render hCdc, 0, 0, bmp_width, bmp_height, 0, 0, bmp_width, bmp_height, 0
for i = 0 to 5
hBmps(i) = CreateCompatibleBitmap(UserControl.hdc, 8, 8)
SelectObject hCdcTemp, hBmps(i)
res = BitBlt(hCdcTemp, 0, 0, 8, 8, hCdc, i, 0, SRCCOPY)
hpen = CreatePen(0, 3, RGB(i * 10, 255, 0))
hbr = CreatePatternBrush(hBmps(i)) ' All for the CreatePatternBrush()
SelectObject UserControl.hdc, hbr
SelectObject UserControl.hdc, hpen
Rectangle hdc, 0, i * 50, 180, 50
next
End Sub
Does anyone know how to draw a bitmap into a memory?
I am trying to use StdPicture.Render , but I can use only hdc object like picturebox, form , etc, unless I get run-time error "Invalid procedure call or argument (Error 5)".But I need draw the bitmap into a memory and after that I want to do sometning with it( for animation in ActiveX).
Thanks!
Dim hBmps(0 to 5) as Long
private Sub UserControl_ReadProperties(PropBag as PropertyBag)
Dim pic as IPictureDisp
Dim hCdc as Long
Dim hCdcTemp as Long
Dim hBmp as Long
Dim i as integer
...
namebmp = PropBag.ReadProperty("namebmp")
...
set pic = LoadPicture(namebmp)
hCdc = CreateCompatibleDC(UserControl.hdc)
hCdcTemp = CreateCompatibleDC(UserControl.hdc)
hBmp = CreateCompatibleBitmap(UserControl.hdc, bmp_width, bmp_height)
SelectObject hCdc, hBmp
pic.Render hCdc, 0, 0, bmp_width, bmp_height, 0, 0, bmp_width, bmp_height, 0
for i = 0 to 5
hBmps(i) = CreateCompatibleBitmap(UserControl.hdc, 8, 8)
SelectObject hCdcTemp, hBmps(i)
res = BitBlt(hCdcTemp, 0, 0, 8, 8, hCdc, i, 0, SRCCOPY)
hpen = CreatePen(0, 3, RGB(i * 10, 255, 0))
hbr = CreatePatternBrush(hBmps(i)) ' All for the CreatePatternBrush()
SelectObject UserControl.hdc, hbr
SelectObject UserControl.hdc, hpen
Rectangle hdc, 0, i * 50, 180, 50
next
End Sub