Mail Archives: djgpp/1999/02/11/18:30:56
It must be just sending the color components separately. You need to split
your 24 bit color bitmap into three 8 bit bitmaps where the pixel color
number in the 8 bit bitmaps is one component for the 24 bit bitmap. Like
this...
(Disclaimer: Untested, quick and dirty, and no error checking. Assumes the
24 bit bitmap is in bbggrr pixel format also. And not very optimized!)
typedef struct {
BITMAP *r; // These should be 8 bit.
BITMAP *g;
BITMAP *b;
} split;
split split_image (BITMAP *bmp) {
// Arg should be 24-bit.
split sp;
int x, y;
unsigned int c;
sp.r = create_bitmap_ex(bmp->w,bmp->h,8);
sp.g = create_bitmap_ex(bmp->w,bmp->h,8);
sp.b = create_bitmap_ex(bmp->w,bmp->h,8);
for (x=0; x<bmp->w; ++x) {
for (y=0; y<bmp->h; ++y) {
c=getpixel(bmp,x,y);
putpixel(sp.r,x,y,c&0xff);
putpixel(sp.g,x,y,c&0xff00);
putpixel(sp.b,x,y,c&0xff0000);
}
}
return sp;
}
Send sp.r, sp.g, and sp.b to the printer in the correct order, then
remember to destroy_bitmap() all three.
--
.*. "Clouds are not spheres, mountains are not cones, coastlines are not
-() < circles, and bark is not smooth, nor does lightning travel in a
`*' straight line." -------------------------------------------------
-- B. Mandelbrot |http://surf.to/pgd.net
_____________________ ____|________ Paul Derbyshire pderbysh AT usa DOT net
Programmer & Humanist|ICQ: 10423848|
- Raw text -