How To Convert BMP 24 bit to BMP 8 bit in VB? 
Author Message
 How To Convert BMP 24 bit to BMP 8 bit in VB?

You can create a DC at any bit depth, after all it's just changing the
number of bits it takes to store each pixel.  The bit depth of the DC is
determined (At least I think this is how it goes, please correct me if I'm
wrong) by the bit depth of the bitmap that's selected into it.  You set the
bit depth of that in the BITMAPINFOHEADER structure.
As long as you keep the image as a DIB then you can work at any bit depth
you want, the only time you have to worry about the screen resolution is
when you convert your DIB to a DDB.
To save the image as an 8-Bit bitmap then you write out the DIB information
to a file.
First you have a BITMAPFILEHEADER type, then the BITMAPINFO type which
consists of one BITMAPINFOHEADER followed by the palette as RGBQUAD type
entries.
Finally the image data is written (Remember to DWord align the scan lines
though) out as a byte stream in the case of and 8-Bit image or packed data
in the case of 1 or 4-bit images, and these simply point to a colour in the
palette.
Hope this helps,

    Mike

 -- EDais --

WWW: http://www.*-*-*.com/




Mon, 07 Jul 2003 19:19:55 GMT  
 How To Convert BMP 24 bit to BMP 8 bit in VB?
I can't understand it very well,please give me some examples,ok?
Thank you!


Quote:
> You can create a DC at any bit depth, after all it's just changing the
> number of bits it takes to store each pixel.  The bit depth of the DC is
> determined (At least I think this is how it goes, please correct me if I'm
> wrong) by the bit depth of the bitmap that's selected into it.  You set
the
> bit depth of that in the BITMAPINFOHEADER structure.
> As long as you keep the image as a DIB then you can work at any bit depth
> you want, the only time you have to worry about the screen resolution is
> when you convert your DIB to a DDB.
> To save the image as an 8-Bit bitmap then you write out the DIB
information
> to a file.
> First you have a BITMAPFILEHEADER type, then the BITMAPINFO type which
> consists of one BITMAPINFOHEADER followed by the palette as RGBQUAD type
> entries.
> Finally the image data is written (Remember to DWord align the scan lines
> though) out as a byte stream in the case of and 8-Bit image or packed data
> in the case of 1 or 4-bit images, and these simply point to a colour in
the
> palette.
> Hope this helps,

>     Mike

>  -- EDais --

> WWW: Http://Members.xoom.com/EDais/





Tue, 08 Jul 2003 08:59:46 GMT  
 How To Convert BMP 24 bit to BMP 8 bit in VB?

Quote:
> I can't understand it very well,please give me some examples,ok?

I gave you all the information you need, for more info on DIB's have a look
at the MSDN, here's an example export routine assuming your headers and such
have already been filled:

'*** Warning: Air code

'Add the following type's from the API viewer:
'    BITMAPFILEHEADER
'    BITMAPINFO
'    BITMAPINFOHEADER
'    RGBQUAD

Dim bmpFH As BITMAPFILEHEADER
Dim bmpInf As BITMAPINFO
Dim ImgData() As Byte
Dim FNum As Integer

Call WriteBmp("X:\Path\FileName.bmp")

Sub WriteBmp(inFile As String)
    FNum = FreeFile

    Open inFile For Binary As #FNum
        Put #FNum, , bmpFH
        Put #FNum, , bmpInf
        Put #FNum, , ImgData()
    Close #FNum
End Sub

'***

Hope this helps,

    Mike

 -- EDais --

WWW: Http://Members.xoom.com/EDais/




Tue, 08 Jul 2003 16:50:17 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. BMP 24-bit to BMP 1-bit converting

2. Convert 16 bit bmp to 24 bit bmp

3. 24 bit BMP to 8 bit BMP

4. How To Convert BMP 24 bit to BMP 8 bit in VB?

5. 24-bit bmp to 1-bit conversion

6. bmp 24-bit to 1-bit conversion

7. How to load a 24 bit bmp picture

8. 24 Bit BMP File Structure

9. Reduce BMP to 8 bit from 24

10. Converting 16/24 bit image to 8 bit

11. Howto change 24 bit bitmap into 8 bit bitmap in vb

12. Q: VB 4.0 32-bit, convert WMF to BMP

 

 
Powered by phpBB® Forum Software