CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 1999
    Location
    Israel
    Posts
    26

    How to draw a bitmap into a memory

    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






  2. #2
    Join Date
    Dec 1999
    Location
    Israel
    Posts
    101

    Re: How to draw a bitmap into a memory

    Try to use Clipboard.SetData method to save your bitmap
    and Clipboard.GetData to load it into your form.
    There is a good example for GetData in VB Help.

    Good Luck!


  3. #3
    Join Date
    Sep 1999
    Location
    Israel
    Posts
    26

    Re: How to draw a bitmap into a memory

    Hi,Ruth!
    Thanks for your try to replay!
    Unfortunaly, the problem was in something other.
    I have found the answer on the http://www.experts-exchange.com
    Good luck!




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured