Subj : color => grayscale To : borland.public.cpp.borlandcpp From : "Stefan Hauser" Date : Thu Apr 15 2004 03:38 pm Hi, I'd like to convert a colored picture to grayscale.The Programm should be a win console application! At the programm start two parameters will be set. the first is the filname of the colored picture and the second one is the path where the grayscaled picture has to be saved! I have found a source at the internet, but I dont understand everything in it! Can you help me? Can somebody tell me how to load a picture into a variable? and how to change this code that it works with theese two parameters. thank you very very much for your help!! kind regards, stefan hauser [C++] void BitmapToGreyScale(Graphics::TBitmap *pBitmap) { LOGPALETTE* plLogPal = NULL; int ilPaletteSize = 0; // Grösse des Buffers für die LOGPALETTE-Struktur pBitmap->PixelFormat = pf8bit; try { // Speicherbedarf für die Palette berechnen und Speicher reservieren: ilPaletteSize = sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * 255); plLogPal = (LOGPALETTE*) malloc(ilPaletteSize); if(plLogPal != NULL) { // Palette initialisieren: plLogPal->palVersion = 0x300; plLogPal->palNumEntries = 256; // Farben in der Palette mit Graustufen-Werten initialisieren: for (int ilColorIndex = 0; ilColorIndex <= 255; ilColorIndex++) { plLogPal->palPalEntry[ilColorIndex].peRed = ilColorIndex; plLogPal->palPalEntry[ilColorIndex].peGreen = ilColorIndex; plLogPal->palPalEntry[ilColorIndex].peBlue = ilColorIndex; plLogPal->palPalEntry[ilColorIndex].peFlags = PC_NOCOLLAPSE; } // Palette erzeugen und zuweisen: HPALETTE hLogPal = CreatePalette(plLogPal); if (hLogPal) pBitmap->Palette = hLogPal; // Speicher wieder freigeben: free(plLogPal); plLogPal = NULL; } } catch ( ... ) { ; } } [END C++] .