Saving Bitmaps 
Author Message
 Saving Bitmaps

How can i save the image property of a picturebox control in the format that
i want (Windows RGB Encoded, BMP 1 Bit (only 2 colors pallete)) .
I currently use Savepicture but it saves it in  16 million colors format
wich and don't need.
If anyone could help me on this i'd be thankfull.


Fri, 10 Aug 2001 03:00:00 GMT  
 Saving Bitmaps


Fri, 19 Jun 1992 00:00:00 GMT  
 Saving Bitmaps
I stripped the relevant parts out of an old program.  Should point you
in the right direction.  There are probably some things missing, but
should be easy to figure the rest out.

Private Type BITMAPFILEHEADER    '14 bytes
   bfType As Integer
   bfSize As Long
   bfReserved1 As Integer
   bfReserved2 As Integer
   bfOffBits As Long
End Type

Private Type BITMAPINFOHEADER   '40 bytes
   biSize As Long
   biWidth As Long
   biHeight As Long
   biPlanes As Integer
   biBitCount As Integer
   biCompression As Long
   biSizeImage As Long
   biXPel{*filter*}eter As Long
   biYPel{*filter*}eter As Long
   biClrUsed As Long
   biClrImportant As Long
End Type

Private Type RGBQUAD
   rgbBlue As Byte
   rgbGreen As Byte
   rgbRed As Byte
   rgbReserved As Byte
End Type

Private Type BITMAPINFO_1
   bmiHeader As BITMAPINFOHEADER
   bmiColors(1) As RGBQUAD
End Type

Private Const PIXEL As Integer = 3
Private Const DIB_RGB_COLORS As Long = 0
Private Const PALVERSION = &H300

'have to set up GetDIBits API
Private Declare Function GetDIBits1 Lib "gdi32" Alias "GetDIBits" (ByVal
aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal
nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO_1, ByVal wUsage As
Long) As Long

'get the bitmap from the picturebox
Retval = GetDIBits1(pic.hDC, pic.Image, 0,
SaveBitmapInfo_1.bmiHeader.biHeight, SaveBits(0), SaveBitmapInfo_1,
DIB_RGB_COLORS)

    ' create a header for the save file
    With SaveFileHeader
       .bfType = &H4D42
       .bfSize = Len(SaveFileHeader) + nLen + BufferSize
       .bfOffBits = Len(SaveFileHeader) + nLen
    End With

    ' save it to disk
    fNum = FreeFile

    Dim elocation As String
    Dim FSys As New FileSystemObject
    Dim elephant As Integer
    elephant = Len(location)
    elocation = Left$(location, 3) & "A" & Right$(location, elephant -
3)
    Debug.Print elocation
    Open elocation For Binary As fNum
    Put fNum, , SaveFileHeader
    Put fNum, , SaveBitmapInfo_1
    Put fNum, , SaveBits()
    Close fNum
    FSys.CopyFile elocation, location, True

Hope this helps.

Quote:
> ----------

> Posted At:         Monday, February 22, 1999 6:04 AM
> Posted To:         internet
> Conversation:      Saving Bitmaps
> Subject:   Saving Bitmaps

> How can i save the image property of a picturebox control in the
> format that
> i want (Windows RGB Encoded, BMP 1 Bit (only 2 colors pallete)) .
> I currently use Savepicture but it saves it in  16 million colors
> format
> wich and don't need.
> If anyone could help me on this i'd be thankfull.



Sun, 12 Aug 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Saving Bitmaps

2. Help! Saving Bitmaps

3. Saving Bitmaps to different color modes

4. saving bitmaps, icons, metafiles in 1 file

5. Saving bitmaps.

6. Saving Bitmaps

7. How to save bitmaps/wav files in Resource File

8. HELP!! - Saving Bitmaps+Data

9. Saving Bitmaps to a Database

10. Saving Bitmaps with SavePicture

11. Saving Bitmaps to a Database

12. Saving bitmaps into a database

 

 
Powered by phpBB® Forum Software