PDA

Click to See Complete Forum and Search --> : Bitmap Blues !!


manoj
Jan 1st, 2000, 02:27 PM
I am doing a project in image processing in Visual basic. I am having some problems regarding bitmap images. I'll detail the problems below.

1) Passing control out of a loop
I am using the following VB code to display the bitmap into an image control. I am taking the values of each pixel from the bitmap file , do some processing, and finally plot each individual pixel on to the image control.Take a look at it.

For x = 1 To head.width
For y = 1 To head.height
img1.PSet (x, y), RGB(r,g,b)
Next y
Next x

The problem with this code is, the user cannot do anything when the bitmap is being displayed, while control is in this loop. I want to give a cancel button to stop the display of the bitmap ie. exit from this loop. Is there a method for this ?

Alternatively, it would be nice if there is a method to speed up the display of the bitmap,like writing the pixel array directly to video memory. [ Using VB only, not using directx ] .In this way, the need for the cancel button would be eliminated.

2)Saving a bitmap

How do I save the image in an image control to a file on the disk in 256 color in BMP format? I used SavePicture method as folows
SavePicture img1.Image, "C:\test.bmp"
The problem is that, it saves the picture in 16 million colors.I cannot use images in 16 Million colors in my project, because I am specifically working with only 256 color bitmaps. Please help.

celsius
Jan 1st, 2000, 03:01 PM
To cancel the loop, you could try using DoEvents and then when a button is pressed, a value becomes true, telling the loop to use Exit Loop

KENNNY
Jan 3rd, 2000, 06:43 PM
yeah, there is a much quicker way of copying the bitmap from file to a picturebox (or anything that has a DC)

basically, u load the image from a file using some API and into a DC. from there, u can use BitBlt to copy it or parts of it to the screen. u can do all sorts of stuff with it :)

try [url]www.vbexplorer.com[\url] or mail me