Results 1 to 4 of 4

Thread: Loading an image to a memory DC

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    159

    Question Loading an image to a memory DC

    Hi all,
    Currently I'm working on a program that makes an extensive use of bitblt Api function to copy images from one picture box to another.

    My questions are:
    1. Will the copying be significantly faster if I'll use memory DC for storing the source picture? (by using CreatCompaibleDC and LoadImage Api functions), and
    2. I would like to hide the picture files from the user, so is there a way to load the pictures to the memory DC from a picture box rather then in a file?
    Any help or a piece of code will be greatly appreciated.
    Last edited by jsbach; Feb 11th, 2003 at 05:52 AM.

  2. #2
    Addicted Member
    Join Date
    Sep 2002
    Location
    Middle Earth
    Posts
    156
    1. Yes.
    2. Instead of a PictureBox, stuff the image into a resource file (VB
    Comes with a resource editor and some built in functions for
    loading the resources at run-time). When you compile the
    application, the image will be physically part of your .exe (and
    not a seperate file on your file system). You code will create
    a compatible DC, load the bitmap resource, select the resource
    into the DC, and then blit it to some destination DC. There are
    gazillions of examples of how to do these things all over the
    forum so I recommend using the 'search' functionalities
    provided.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    159
    Hi Crunchy Cat,
    After I posted this thread I made some tests to see how faster is bitbliting from a memory DC vs picture box. surprisingly, all tests showed that there are not any advantage to memory DC over
    picture box when speed is in concern. Apparently in both method the data is being read directly from memory. If you want I'll post the code I used for testing.
    As for the other one, I guess it can be worked out this way.
    Thanks allot!

  4. #4
    Addicted Member
    Join Date
    Sep 2002
    Location
    Middle Earth
    Posts
    156
    Hi jsbach, I should have been more specific. The actual blit
    operation shouldn't really take any additional time. It's the
    control's instantiation and picture loading that takes un-
    necessary time. If you had to keep 10 DCs active at any given
    time, then 10 memory DCs will be alot less resource draining than
    10 picture boxes .

    -CC

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