Board index » delphi » Draw 16-COLOR bitmap parts

Draw 16-COLOR bitmap parts

I have an array of all my images as one (16 color) bitmap. 16 color supplies
all the color I need while minimzing the rather large memory footprint.

I use Canvas.CopyRect to the individual images to locations on my scroll
box. Two of the images are intended as overlays. They have a white
background, (intended to be transparent), but I can change that color, if
needed. I use a CopyMode of cmSrcAnd to overlay one of them (according to
state) onto one of the other images on the scrollbox. I tried other
CopyMode's as well, but they gave pretty bad results. This one gives some
color distortion.

Apperently I'll have to do something different to merge in the overlays. Do
I need to convert the images to 24-bit and copy them to a separate (small)
bitmap before merging them, then convert them back (if so how?) or what?
Help!

Thanks,
Jon

 

Re:Draw 16-COLOR bitmap parts


Quote
> I use a CopyMode of cmSrcAnd to overlay one of them (according to
> state) onto one of the other images on the scrollbox.

Delphi online help says "BrushCopy is provided mainly for backward
compatibility" but BrushCopy sometimes seems to be the best way to put a
bitmap over something else. Try Brush.Style := bsClear and then
Canvas.BrushCopy

Jens

Re:Draw 16-COLOR bitmap parts


Thank you. That works!

It takes an incredibly long time to make the copy, however. A full second
just to BrushCopy a single rectangle 141 pixels wide by 201 pixels high.
Sometimes I will have to do this 7 times from a single button click, which
would take about 7 seconds, but it has to appear virtually instantaneous to
the user.

Any suggestions?

Thanks,
Jon

Quote
"Jens Gruschel" <j...@pegtop.net> wrote in message

news:3CADF22B.2F4C09ED@pegtop.net...
Quote
> > I use a CopyMode of cmSrcAnd to overlay one of them (according to
> > state) onto one of the other images on the scrollbox.

> Delphi online help says "BrushCopy is provided mainly for backward
> compatibility" but BrushCopy sometimes seems to be the best way to put a
> bitmap over something else. Try Brush.Style := bsClear and then
> Canvas.BrushCopy

> Jens

Re:Draw 16-COLOR bitmap parts


I found a way. I made the two overlays be separate, small bitmaps, which I
load separately into memory. BrushCopy works fast enough if the source
bitmap is small. Too bad the speed of the copy depends on the size of the
whole bitmap instead of the size of the region being BrushCopied.

Jon

Quote
"Jon Jacobs" <jqjac...@gte.net> wrote in message news:3cae1784$1_1@dnews...
> Thank you. That works!

> It takes an incredibly long time to make the copy, however. A full second
> just to BrushCopy a single rectangle 141 pixels wide by 201 pixels high.
> Sometimes I will have to do this 7 times from a single button click, which
> would take about 7 seconds, but it has to appear virtually instantaneous
to
> the user.

> Any suggestions?

> Thanks,
> Jon

> "Jens Gruschel" <j...@pegtop.net> wrote in message
> news:3CADF22B.2F4C09ED@pegtop.net...
> > > I use a CopyMode of cmSrcAnd to overlay one of them (according to
> > > state) onto one of the other images on the scrollbox.

> > Delphi online help says "BrushCopy is provided mainly for backward
> > compatibility" but BrushCopy sometimes seems to be the best way to put a
> > bitmap over something else. Try Brush.Style := bsClear and then
> > Canvas.BrushCopy

> > Jens

Re:Draw 16-COLOR bitmap parts


Quote
> It takes an incredibly long time to make the copy, however. A full second
> just to BrushCopy a single rectangle 141 pixels wide by 201 pixels high.

It takes much less on my system. I guess it depends on the graphics
driver you use. Maybe I should think about not using it any more, if it
takes that long on some systems...

Jens

Other Threads