Results 1 to 3 of 3

Thread: Reading Picture Files

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987

    Question

    Anybody know how to get a picture loaded from a file directly into a DC without having to display it in a picturebox and bitblt it to the dc.
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    See the demo project on my website

  3. #3
    Lively Member
    Join Date
    May 2000
    Posts
    84
    In your module declare these functions and variables:

    ________________________________

    'API FUNCTIONS
    Public Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long

    Public Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long

    Public Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long

    Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

    'Variables
    Public MyPicture_DC as long
    _________________________________

    Then write a function to load the image:
    _________________________________

    Sub Create_DC()

    MyPicture_DC = CreateCompatibleDC(0)
    SelectObject MyPicture_DC, LoadPicture("C:\MyPic.BMP")

    End Sub
    _________________________________

    Now now MyPicture_DC contains the image and you can use Bitblt with it later.
    Also in you form unload method use

    DeleteDC MyPicture_dc

    so that you free up image memory when your done the program.


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