Link to home
Start Free TrialLog in
Avatar of patricksd
patricksd

asked on

General BitBlt question in VB

I have been experimenting with the BitBlt command in VB and can't seem to get the results that I want. What I want to do is load a picture in one picturebox and copy it over to another picturebox utilizing stretch or transparent modes. I can get this to work ONLY if both pictureboxes are visible on the screen, which is not what I want. I want the source hidden either not visible or off the screen. How can I get this to work? As a side note, I am using eVB which has very limited picturebox commands. It does not support LoadPicture which I know is an alternate way of getting what I want in VB6.

Can someone explain why the source picturebox must be visible on the screen for BitBlt to work? I thought it was just copying a memory map from one object to another, so why does it have to be visible? Does anyone have a solution for what I want?
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Try set the target picturebox's AutoRedraw Property to True?

like:

Picture2.AutoRedraw = True
Avatar of AndyAmess
AndyAmess

I had a few problems with eVB and picture box so I switched to this freeware control and find it much better. It also has ability to use other formats and is much more fun to use.

http://www.yetanotherhomepage.com/j7xx/j7xx.html?/j7xx/software/prog/s309pict.html

A. ;-)
Avatar of patricksd

ASKER

Regarding Autoredraw, eVB does not support that feature. I had already tried the S309 control but found it to be too slow for loading many transparent .gifs  at a large screen resolution. Somehow the transparency bogs it down. Using the API TransparentImage seems to work much faster, but the problem is the source picturebox must be visible on the screen for it to work. Plus it seems that when another event happens, the destination picturebox loses the changes. So either way, I am not happy with BitBlt that everyone recommends using, unless I am using it wrong. If anything, I want to understand what is going on.
Just a suggestion, try setting the zorder such that both picture box's are visible but one is behind the other.

Frank
Zorder doesn't help. It appears to rely on the screen image for data as opposed to the data stored in the picturebox. Perhaps they are one in the same?
Set Picture2.Picture = Picture1.Picture

Does eVB atleast support that? :-)

Concerning copying DCs of hidden windows..
http://www.fengyuan.com/article/wmprint.html
To comment on what I mentioned about (Set Picture2.Picture = Picture1.Picture)..

If the above works, you'll have the hidden picture in the visible PictureBox. Then you may be able to use that as a source and destination for BitBlt. If not, you can try creating a memory-dc, applying the stretch/transparency to that, then bitblt'ing it back to the visible portion.

Additionally, check out: https://www.experts-exchange.com/questions/20944169/Pixel-by-pixel-analysis-of-a-picture.html

You can possibly use the same method in the above to get the bits of the picture, modify them and then repaint them to the destination picturebox.
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial