Re: Text is white when drawn into a lock-focused NSImage

101 views
Skip to first unread message

Christopher Lloyd

unread,
Dec 18, 2012, 4:07:29 PM12/18/12
to cocotr...@googlegroups.com
Hey Jayson, apologies for your message being stuck in the moderation queue. Welcome! I remember NewsGrazer :)

This bug could be in a variety of places, it's probably in the Onyx2D/CoreGraphics stuff, depends on the bitmap format, blend mode, color, color space, etc. If it works on-screen then the fix is probably simple.

Can you distill it into a simple example?

Chris


On Saturday, December 15, 2012 6:37:54 PM UTC-5, Jayson Adams wrote:
Hello,

If I lockFocus on an NSImage and call drawRect: on an NSTextView, the text that gets drawn is white and fuzzy instead of black and crisp.  Does anyone know why this would happen and how to work around or fix it?

Best,

__jayson

Jayson Adams

unread,
Dec 19, 2012, 1:41:23 AM12/19/12
to cocotr...@googlegroups.com
Wow, NewGrazer - those were the days....

Thank you for the reply, Chris.  Impressive work here with the Cocotron!!

Yes, I do have a simple example, which I will attach to this message.  Within it, the BitmapTest.xcodeproj builds the Cocoa version and BitmapTest-Windows.xcodeproj builds it for Windows.  When you run on the Mac you'll see that the text looks black and sharp as you'd expect, but it's white and fuzzy on Windows.

Best,

__jayson
BitmapTest.zip

Christopher Lloyd

unread,
Dec 23, 2012, 1:32:20 AM12/23/12
to cocotr...@googlegroups.com
Hey Jayson,

Not sure what your requirements are but if you need to use text in bitmaps you'll probably want to use the AntiGrain plugin, the O2Context_AntiGrain project. This is a bundle which sits inside AppKit and depends on the AntiGrain library to do rendering.

The basic problem is right now I'm using GDI to draw text and GDI doesn't understand alpha, it renders the text with alpha=0. Or more correctly, I don't use the GDI text bitmaps as stencils properly. So, when you source over your bitmap, it's actually showing the background color through this text. If you draw the image with Copy it shows up black, it'd still be copying alpha=0 but ultimate drawing on-screen in an opaque window ignores alpha so you get black, in a non-opaque window it'd create see through text.

So, the text is black, but alpha is 0...

Chris

 

Jayson Adams

unread,
Jan 2, 2013, 3:07:10 PM1/2/13
to cocotr...@googlegroups.com
Hi Chris,

Thanks for the tip! The AntiGrain plugin works great, and actually solves a number of other drawing-related issues I was seeing.

What is the best way to submit Cocotron changes/fixes?  I've found a couple crashers, one of them being fairly tricky to track down.

Best,

__jayson

Christopher Lloyd

unread,
Jan 3, 2013, 10:15:31 AM1/3/13
to cocotr...@googlegroups.com


On Wednesday, January 2, 2013 3:07:10 PM UTC-5, Jayson Adams wrote:
Thanks for the tip! The AntiGrain plugin works great, and actually solves a number of other drawing-related issues I was seeing.

Great! 
 

What is the best way to submit Cocotron changes/fixes?  I've found a couple crashers, one of them being fairly tricky to track down.


What I ask people to do is to create a clone of cocotron here: http://code.google.com/p/cocotron/source/checkout  the Create a clone button. Push your fixes to this clone, then myself and others can pull changes from your clone. You can also pull changes from the other clones which are of interest.

If you want to create issues for the changes that's great but not a requirement.

I don't pull changes into the mainline frequently, so please just leave your clone alive indefinitely if it has useful changes.

Thanks!
Chris
 

Pauli Ojala

unread,
Jan 3, 2013, 11:02:03 AM1/3/13
to cocotr...@googlegroups.com
Hi Jayson,

from my point of view as a Cocotron user, it would be great if you could create issues for the changes and fixes that are in your Cocotron clone.

When debugging Cocotron apps, it's always a relief if other people's changes can be found be searching the issue database, rather than going blindly hunting into everybody's clones in the hopes that there might be something useful…

The issues don't need to be thorough -- just a few lines describing what part of the framework is affected is always infinitely better than nothing!


Best regards,

Pauli
> --
> You received this message because you are subscribed to the Google Groups "Cocotron Developers" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/cocotron-dev/-/bMiTU8bSFxQJ.
> To post to this group, send email to cocotr...@googlegroups.com.
> To unsubscribe from this group, send email to cocotron-dev...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cocotron-dev?hl=en.

Jayson Adams

unread,
Jan 3, 2013, 4:00:08 PM1/3/13
to cocotr...@googlegroups.com
Hi Chris,

OK, I will submit changes via a clone.  And Pauli, makes sense - I will also create issues for my changes.

Best,

__jayson

Reply all
Reply to author
Forward
0 new messages