|
From: | Scott Christley |
Subject: | Re: drawing to NSImage off display |
Date: | Mon, 11 May 2009 15:33:46 -0700 |
Hello Fred,I've filed bug # 26535 for this issue and attached a test app illustrating the problems. There is an issue with threads as the app illustrates but there is also an issue with scaling.
https://savannah.gnu.org/bugs/?func=detailitem&item_id=26535 thanks Scott On May 11, 2009, at 12:14 PM, Scott Christley wrote:
Hello Fred,I think I'm mistaken about it working before, well my program was working before but the drawing code was architected differently. I coded it to be more efficient, but this was done on Mac. I thought that it worked with the stock GNUstep that you get on Debian, but I tried that over the weekend and no go, that actually crashes when it tries to draw in the NSImage. So I don't think I ever got the new code working with GNUstep yet.Anyways, I did discover a few things. There seems to be a combination of issues.* It is *not* an issue with images loaded from files; those seem to work fine in all cases, so it seems to be primarily related to allocated images that you then attempt to draw within and then display.* Scaling is not working for allocated images. However if I don't scale the image, then I can get it to display (under the right conditions).* Doesn't seem to be an issue with threads. Have the same problem both in the main and secondary threads, though this is confounded by the next issue.* A key issue is that drawing into the image does not appear to work unless I do it within the context of NSView's -drawRect: method. So if I draw into the image in a target-action method (say) from a button click, then try to compose that image into a view, it doesn't work. If I draw into the image during drawRect: then it appears to work, but I have the scaling issue mentioned above when composing.I will work on a constructing a small test application that shows these different combinations.cheers Scott On May 9, 2009, at 7:38 AM, Fred Kiefer wrote:Hi Scott,when you are saying that it worked before, at what time was that? A few days ago, weeks, months? As far as I know, drawing in a separate thread should have produced an error up until two months ago.Is your code working when executed in the main thread? If not we should try to get it working there first.Is there already anything in that image you are drawing on?It would be helpful if you could send full working code to reproduce the problem, then sonebody could look at your code directly and also test whether it works on his machine. That somebody couldn't be me at the moment, as I am travelling, but as soon as I am back I would test your code.FredPS: There was a similar bug report some time ago, but this is fixd and closed now. Perhaps you could have a look at that.-------- Original-Nachricht --------Datum: Fri, 08 May 2009 18:45:00 -0700 Von: Scott Christley <schristley@mac.com> An: gnustep <discuss-gnustep@gnu.org> Betreff: drawing to NSImage off displayHello,Some code which use to work is no longer working and I'm not sure why.I use some worker threads to do computation, then they draw into theirown personal NSImage objects, which are then passed over to the main GUI thread to be displayed. It seems that the drawing into the NSImage is not working properly. The method for each worker thread looks somewhat like this: - doWork { // do some stuff [image lockFocus]; [[NSColor greenColor] set]; NSRectFill(aRect); // do some more drawing [image unlockFocus]; }Is there any reason why drawing into NSImage, either off display or inworker threads, should not work? I verified that nothing is wrong with the rest of my code, because Ican change that -doWork method to just load an image from a file, likethis, and the image displays just fine: image = [[NSImage alloc] initWithContentsOfFile: file]; On a secondary note, I tried saving the image to a file, after I - unlockFocus, but it produces a corrupt file. [[image TIFFRepresentation] writeToFile: file atomically: NO]; I'm using GNUstep from SVN, on Debian with the art backend. thanks Scott _______________________________________________ Discuss-gnustep mailing list Discuss-gnustep@gnu.org http://lists.gnu.org/mailman/listinfo/discuss-gnustep--Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate + Telefonanschluss für nur 17,95 Euro/mtl.!* http://dslspecial.gmx.de/freedsl-surfflat/?ac=OM.AD.PD003K11308T4569a_______________________________________________ Discuss-gnustep mailing list Discuss-gnustep@gnu.org http://lists.gnu.org/mailman/listinfo/discuss-gnustep
[Prev in Thread] | Current Thread | [Next in Thread] |