Click here to Skip to main content
15,914,905 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCRecordset Pin
Bravoone_20061-Feb-07 19:41
Bravoone_20061-Feb-07 19:41 
QuestionRe: CR Pin
prasad_som1-Feb-07 19:49
prasad_som1-Feb-07 19:49 
AnswerRe: CRecordset Pin
David Crow2-Feb-07 3:06
David Crow2-Feb-07 3:06 
AnswerRe: CRecordset Pin
Mark Salsbery2-Feb-07 7:21
Mark Salsbery2-Feb-07 7:21 
QuestionConvertin 24 bit Bitmap file to 8 bit Bitmap Pin
Vijjuuu.1-Feb-07 19:24
Vijjuuu.1-Feb-07 19:24 
AnswerRe: Convertin 24 bit Bitmap file to 8 bit Bitmap Pin
Waldermort1-Feb-07 19:31
Waldermort1-Feb-07 19:31 
GeneralRe: Convertin 24 bit Bitmap file to 8 bit Bitmap Pin
Vijjuuu.1-Feb-07 19:43
Vijjuuu.1-Feb-07 19:43 
GeneralRe: Convertin 24 bit Bitmap file to 8 bit Bitmap Pin
Waldermort1-Feb-07 20:00
Waldermort1-Feb-07 20:00 
There is no direct formula for converting.

Look at the GDI references for bitmaps on MSDN. The BITMAPINFO contains a BITMAPINFO header which details the bitmap, and an array of RGBQUAD structures which is the colors used in the pallette. To convert using a DIB, first create that array of RGBQUAD structures, and use it to create a pallette ( The colors you use depend on you).

Then for each RGB pixel value in the 24-bit bitmap call GetNearestPaletteIndex(), this will give you the index of the color in the pallette you just created. Use this index as the pixel value in your new 8-bit bitmap. Ultimatly you want to build a new array of pixel values.

To save, all you need to do is create a new BITMAPINFO and BITMAPINFOHEADER for the new image, using the new array of RGBQUAD's and the new array of pixel values.

To get you started, look at Chris Maunders DIB wrapper here[^].

If you let the OS do the convertion for you, it will use the standard color pallette. In most case this is not a problem, but the standard pallette contains a range of all the colors from white to black. If your bitmap contains mostly the color green for example, you will lose a lot of colors since the pallette has colors you don't want to use.

Most paint programs will scan the image before doing a bitdepth conversion, and create a pallette that contains only the colors in the bitmap. You will still lose a lot of colors but not as many as with using a standard pallette.
GeneralRe: Convertin 24 bit Bitmap file to 8 bit Bitmap Pin
Vijjuuu.1-Feb-07 21:50
Vijjuuu.1-Feb-07 21:50 
GeneralRe: Convertin 24 bit Bitmap file to 8 bit Bitmap Pin
Waldermort2-Feb-07 2:51
Waldermort2-Feb-07 2:51 
AnswerRe: Convertin 24 bit Bitmap file to 8 bit Bitmap Pin
Christian Graus1-Feb-07 19:41
protectorChristian Graus1-Feb-07 19:41 
GeneralRe: Convertin 24 bit Bitmap file to 8 bit Bitmap Pin
Vijjuuu.1-Feb-07 19:46
Vijjuuu.1-Feb-07 19:46 
GeneralRe: Convertin 24 bit Bitmap file to 8 bit Bitmap Pin
Christian Graus1-Feb-07 20:26
protectorChristian Graus1-Feb-07 20:26 
AnswerRe: Convertin 24 bit Bitmap file to 8 bit Bitmap Pin
Mark Salsbery2-Feb-07 7:29
Mark Salsbery2-Feb-07 7:29 
QuestionValue of dmPaperSize in DEVMODE structure for custom papersize Pin
vcpgmr1-Feb-07 19:18
vcpgmr1-Feb-07 19:18 
AnswerRe: Value of dmPaperSize in DEVMODE structure for custom papersize Pin
KKumarTG1-Feb-07 19:55
KKumarTG1-Feb-07 19:55 
GeneralRe: Value of dmPaperSize in DEVMODE structure for custom papersize Pin
vcpgmr4-Feb-07 17:31
vcpgmr4-Feb-07 17:31 
AnswerRe: Value of dmPaperSize in DEVMODE structure for custom papersize Pin
Hamid_RT2-Feb-07 5:52
Hamid_RT2-Feb-07 5:52 
Questionhow to write and read into files using vc++ Pin
prem.makal1-Feb-07 18:46
prem.makal1-Feb-07 18:46 
AnswerRe: how to write and read into files using vc++ Pin
Hans Dietrich18-Feb-07 0:19
mentorHans Dietrich18-Feb-07 0:19 
QuestionError in using Unicod DLL in non unicode Application Pin
Atul231-Feb-07 18:18
Atul231-Feb-07 18:18 
AnswerRe: Error in using Unicod DLL in non unicode Application Pin
Naveen1-Feb-07 19:08
Naveen1-Feb-07 19:08 
GeneralRe: Error in using Unicod DLL in non unicode Application Pin
Atul231-Feb-07 19:33
Atul231-Feb-07 19:33 
GeneralRe: Error in using Unicod DLL in non unicode Application [modified] Pin
Naveen1-Feb-07 19:44
Naveen1-Feb-07 19:44 
GeneralRe: Error in using Unicod DLL in non unicode Application Pin
Atul231-Feb-07 23:35
Atul231-Feb-07 23:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.