June 18, 2024, 10:28:12 AM


IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!

Modifying a bitmap save routine

Started by TexasPete, December 09, 2010, 03:19:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


December 09, 2010, 03:19:09 PM Last Edit: December 10, 2010, 11:02:41 AM by TexasPete
 I am trying  to modify the bitmap save code below. Most of this code was pulled out of an example found in an old ib program.
This code was designed to read from the screen. I would like to modified it to simply accept  the handle of the bitmap and input the
location to save the bitmap in the "savefilename" . Do all I have to do is elliminate  the screen part of the code and  Put the handle number in
"hdcWin" and save the file.  I have tried loading a bitmap and then passing the handle to hdcWin , But it only save a blank Screen. Is there a way
to pass the handle without getting the handle from the screen,?

SUB SaveBitmap( handle, savefilename)
'Modification of Paul Turley's bmp saving routine.
'This one saves the bmp whose handle is *bitmap*
'which will be the last one displayed by the program.
'(Paul's original code grabbed the image from the window.)

def hdcWin,quadsize:int
def lpbits,lpbminfo:MEMORY
def file:BFILE
hdcWin = GetHDC(w1)
'fill in the BITMAPINFOHEADER and compute the color data
quadsize = CreateInfoStructure(w1,bitmap,info)
'allocate memory and get the 'bits' of the bitmap
allocmem lpbits,1,info.biSizeImage
allocmem lpbminfo,1,len(info) + quadsize
writemem lpbminfo,1,info
'open a binary file and write the header,color data and bitmap bits
if(openfile(file,savefilename,"W") = 0)
fileheader.bfType = 0x4d42
fileheader.bfSize = len(fileheader) + info.biSize + quadsize + info.biSizeImage
fileheader.bfOffBits = len(fileheader) + info.biSize + quadsize
write file,fileheader
write file,lpbminfo
write file,lpbits
closefile file
freemem lpbminfo
freemem lpbits
ReleaseHDC w1,hdcWin

In help in pointing me in the right direction would be helpful.

Texas Pete