Results 1 to 4 of 4

Thread: Creating a Bitmap

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Leeds, UK
    Posts
    287

    Smile

    Hi,

    In have made a program that takes a screen shot of the desktop using the GetDesktop and GetDC APIs. After storing the DC in a long called lngPic I would like to turn this into a bitmap but not save it on the hard disk. Any ideas?
    rino_2
    Visual Basic, HTML
    Please Visit my Site: Richard's VB Site

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Use BitBlt api to blit it on a picture, which you save with Savepicture
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    err what do you mean turn it to a bitmap and not save it on the hard drive, by taking the screenshot it is already a bitmap in memory, do you mean get at its bitmap handle? if so you want to use the selectobject, deleteobject and createcompatiblebitmap apis

    Code:
    Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDC As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
    
    
    Public Function BitmapFromDC(ByVal hDC As Long) As Long
    
    Dim retval As Long
    
    retval = SelectObject(hDC, CreateCompatibleBitmap(hDC, 1, 1))
    DeleteObject SelectObject(hDC, retval)
    
    BitmapFromDC = retval
    
    End Function
    hope that's what you wanted.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Leeds, UK
    Posts
    287

    Thumbs up

    Sorry I wasn't clear with the question Sam Finch but you answered my question brilliantly. Thats exactly what I wanted to know. Thanks

    [Edited by rino_2 on 08-11-2000 at 03:42 PM]
    rino_2
    Visual Basic, HTML
    Please Visit my Site: Richard's VB Site

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