DIBSection and ColorTable

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

DIBSection and ColorTable

kruger
Hi,
I'm trying to assign a color table from an instance of DIBSection to
another but after assignment something goes wrong because no one of the
images can be displayed on an ImagePresenter.

I tried this in a Workspace

"The 2 BMP files are identical except for the color tables one contains
grayscale values (RGB(0,0,0) to RGB(255,255,255)) and the other redscale
values (RGB(255,0,0) to RGB(255,255,255))"

a := DIBSection fromFile: 'grayscale.bmp'.
b := DIBSection fromFile: 'redscale.bmp'.
ImagePresenter showOn: a. "OK"
ImagePresenter showOn: b. "OK"
a setColorTable: b getColorTable.
ImagePresenter showOn: a. "FAIL"
ImagePresenter showOn: b. "FAIL"

Then I also tried this:
a := DIBSection fromFile: 'grayscale.bmp'.
ImagePresenter showOn: a. "OK"
a getColorTable.
ImagePresenter showOn: a. "FAIL"


Thanks.


Reply | Threaded
Open this post in threaded view
|

Re: DIBSection and ColorTable

Ian Bartholomew-5
> I'm trying to assign a color table from an instance of DIBSection to
> another but after assignment something goes wrong because no one of the
> images can be displayed on an ImagePresenter.

I can remember problems associated with the DIBSection's handling of colour
tables but not the actual details. I got around this, and one or two other
problems, by creating a DeviceIndependentBitmap class which, as far as I am
aware, does enable colour tables to be copied.  It's available for free as
one of my goodies for Dolphin 4 and as part of the BitmapEditor package in
the D3 goodies.  It might be worth trying it out and, assuming it works for
you, either using it as it stands or as a comparison to see why DIBSection
fails.

Regards
    Ian

http://www.iandb.org.uk


Reply | Threaded
Open this post in threaded view
|

Re: DIBSection and ColorTable

Blair McGlashan
In reply to this post by kruger
"kruger" <[hidden email]> wrote in message
news:[hidden email]...
> Hi,
> I'm trying to assign a color table from an instance of DIBSection to
> another but after assignment something goes wrong because no one of the
> images can be displayed on an ImagePresenter.
>...

I think this is probably due to bug #404, patch attached.

Basically the problem is that a number of operations on Bitmaps/DIBSections
in Dolphin cause the Bitmap to be selected into a memory DC by Dolphin. The
DC is cached for future use, but the standard Windows "Static" control will
not draw a Bitmap that is selected into a DC. As the default view for an
ImagePresenter is a StaticBitmap (the Dolphin class wrapping the "Static"
control in Bitmap mode), nothing is displayed.

Regards

Blair

---------------------------------

"#404: Default view of ImagePresenter (a StaticBitmap) will not display a
programmatically drawn or altered bitmap"!

!StaticBitmap methodsFor!

setImage: aBitmapOrNil
 "Private - Sets aBitmapOrNil into the receiver. Make sure it is a shared
copy
 and that it is not selected into its DC."

 image := aBitmapOrNil notNil ifTrue: [aBitmapOrNil asSharedCopy freeDC;
yourself].
 self sendMessage: STM_SETIMAGE wParam: IMAGE_BITMAP lParam: image
asParameter! !
!StaticBitmap categoriesFor: #setImage:!accessing!private! !