Nice I learned something :).
Stef
On Thu, Dec 28, 2017 at 11:42 PM, Andy Burnett
<andy.burn...@knowinnovation.com> wrote:
> Nicolai wrote
>>>>
>
> You can draw a new form with copybits and use your own color mapping.
>
> First, I thought there would be a bitblt operation that you could use
> without explicit calculating the color mapping, a paint operation that
> would convert a gray-value to an alpha value. But I could find it.
>
> In this special case (black text on white background) you can use an
> existing method for calculating this color map. This method is used by
> strike font to create apropriate glyph forms from its font bitmap. (A large
> bitmap with black characters on a white background.)
>
> Here is an example that first, creates a form with black text on white
> background, and than computes the color map and copys the source form in a
> new form:
>
> "create a test form "
> sourceForm := Form extent: 300@150 depth: 32.
> sourceForm fillColor: Color white.
>
> "draw some black, bold text"
> text := 'Hello World' asText.
> text addAttribute: (TextFontReference toFont: (LogicalFont familyName:
> 'Source Sans Pro' pointSize: 32)).
> text addAttribute: (TextColor color: Color black).
> text addAttribute: (TextEmphasis bold).
> text asMorph drawOn: sourceForm getCanvas.
>
> "create a morph for displaying this form"
> sourceImageMorph := ImageMorph withForm: sourceForm.
> sourceImageMorph openInWorld; topLeft: 300@300.
>
> "calculate the colormap"
> colorMap := Color computeColorConvertingMap: Color black from: 32 to: 32
> keepSubPixelAA: false.
>
> "copy the source form bits to a new form of the same size"
> newForm := sourceForm deepCopy copyBits: sourceForm boundingBox from:
> sourceForm at: 0@0 colorMap: (colorMap).
>
> "create a morph for displaying this form"
> newImageMorph := ImageMorph withForm: newForm.
> newImageMorph openInWorld; topLeft: 300@500.
>
> <<<
>
> Thanks Nicolai
> That is very helpful. However, I agree with you that this is probably
> something BitBlt should be able to handle. I have been looking at how they
> do this in mathematica, and they have some interesting approaches.
>
> Cheers
> Andy