Quantcast
Channel: VBForums - API
Viewing all articles
Browse latest Browse all 168

How do I make GetDIBits use a different palette?

$
0
0
When converting a small sprite graphic from 24bit color to 4bit color I am using this:

Code:

'declares go here

'main code
Dim Info As BITMAPINFO
Dim PixBlock(31) As Byte
With Info.bmiHeader
.biBitCount = 4
.biPlanes = 1
.biWidth = 8
.biHeight = 8
.biSize = 40
.biSizeImage = 32
End With
For n = 0 To 15
Info.bmiColors(n).rgbRed = C64Pal(0, n)
Info.bmiColors(n).rgbGreen = C64Pal(1, n)
Info.bmiColors(n).rgbBlue = C64Pal(2, n)
Next n
GetDIBits Picture1.hdc, Picture1.Image, 0, 8, PixBlock(0), Info, 0
SetDIBits Picture1.hdc, Picture1.Image, 0, 8, PixBlock(0), Info, 0

This causes it to convert the 8x8 TrueColor image in the picture box into a 4bitperpixel 8x8 image. But it doesn't use the palette I specified in the Info.bmiColors. Instead GetDIBits overrides the info I manually placed in the palette which was
Code:

For n = 0 To 15
Info.bmiColors(n).rgbRed = C64Pal(0, n)
Info.bmiColors(n).rgbGreen = C64Pal(1, n)
Info.bmiColors(n).rgbBlue = C64Pal(2, n)
Next n

by replacing it with the windows default palette. When converting any truecolor image into an Indexed Color (palettized color) image, the GetDIBits command is supposed to use the "nearest color" method to find the correct palette. But it ALWAYS USES WINDOWS DEFAULT PALETTE as the palette for conversion. I want to be able to specify my OWN PALETTE (in this case I'm trying for the Commodore 64 color palette). Please help me to set the palette that GetDIBits uses when converting to indexed color images.

Viewing all articles
Browse latest Browse all 168

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>