VB6 Paint image in memory?

kevinthenerd

Platinum Member
Jun 27, 2002
2,908
0
76
This is for data analysis for scientific research. I know VB isn't the best choice for such things, but I have my reasons.

I have a couple of images. I have a small algorithm that, pixel by pixel, performs a calculation based on these two images to produce a third image. The code is slow because it draws the entire operation as it happens.

Right now, I'm using three picturebox controls, and I'm calling the points with Point and Pset for reading and writing, respectively. The images are copied over between various sources by copying the Image property, using LoadImage, and by using SaveImage.

How do you work with the Image data type that VB gives you? Is there a way to load an image in RAM, manipulate it pixel-by-pixel, and then write it back to a file without ever consuming resources with the GUI?

Thanks.
 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
The Image property is of type IPictureDisp and is actually in memory already. You might have to convert (memory-wise) it to DIB format first, but you can extract bits out of it.

These resources may be helpful:

http://msdn.microsoft.com/library/en-us/dngdi/html/msdn_dibs2.asp?frame=true
http://www.vbaccelerator.com/codelib/gfx/dibsect.htm
http://www.google.com/search?hl=en&q=GetDIBits
http://www.activevb.de/tipps/tipkat/kat4.html

I think this is what you may be trying to do: http://www.activevb.de/tipps/vb6tipps/tipp0431.html

If you're still having trouble I might be able to cook up an example for you.