Solved

How to convert 24-bit DIB to 4-bit DIB ?

Posted on 1998-03-28
2
350 Views
Last Modified: 2013-11-20
If I save a 24-bit DIB as .BMP-file it's about 1.8 MB large. I don't have so much colors in the DIB so it gives also enough good results to reduce to 4-bit colors. I tried it with MS-PAINT. MS-Paint allows you to convert to 4 bit and the result is very good and the file-size reduces to nearly 300 kB. Is there anywhere source-code in VC++ in doing this converting from own programs written in C++ ?

Thanks a lot
0
Comment
Question by:atari
2 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1317315
The idea is that you have 16 colors to which map everything else. The bad thing about this is that the 16 colors are already chosen for you. They exists in the standard VGA color palette. So basically, for every RGB you have, you need to figure out the distance between that RGB with the RGB of the standard colors to see which it is closest to. Then you change that RGB to the standard color.


0
 
LVL 1

Author Comment

by:atari
ID: 1317316
I've heard upon that, you have 20 ground colors in the standard-palette and the routines you find  for converting are calculating the "nearest colors". I've seen sample-code for that. But this is not the main problem. In the 24-bit-DIB the color information is inside the pixels and there is no color palette. If I want to reduce the DIB to 16 colors I need a color-palette, there I found somewhere in MSJ a sample-code "palette generator", but the main problem is to filter out the color-information out of the pixels, that include also the color-information if you have a 24-bit-DIB. Some sample-code would be very nice. There can nothing be found around the whole internet. I tested also Paint Shop Pro and this program also reduces the colors in a fine way. There must be some sample-code for it.

Thanks,
atari
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
EvenOdd challenge 10 125
Fibonacci challenge 11 132
Trying to run powershell  in a batch file. How do I do this? 8 105
Making an alias 7 101
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question