[Mono-list] LockBits() on Mono 2.2?

LKeene lionel.keene at gmail.com
Fri Mar 20 11:40:12 EDT 2009


I actually intend to use it to draw to a memory bitmap pixel-by-pixel, rather
than calling SetPixel() each time. Apparently that would be extremely slow
form what I've read online. The only alternative to Set/GetPixel() seems to
be declaring an unsafe block and using LockBits(). I'll try to test the mono
LockBits() implementation today, but assuming that there is indeed a bug,
does anyone have any other ideas of how to accomplish drawing to a memory
Bitmap other than SetPixel()? I have a precomputed "Color[,]" that specifies
the pixels colors.

Thanks all.
-L



Stifu wrote:
> 
> I intended to file the bug (and still do), but the program I have on my
> hands as is requires you to open a game ROM file first, which is something
> I didn't want people to bother with.
> It's definitely on my todo list, though.
> 
> In my program, I found a workaround (which is a little bit slower, but
> that can't be noticed since it's blazing fast anyway). Here's that part of
> my code:
> 
> if (PlatformInformation.IsMono()) // HACK Clone bug workaround (Mono only)
> {
> 	// Slower than simply cloning the tile bitmap, but works with Mono
> 	// Cloning the tile bitmap returns a black tile with Mono
> 	this.tileClipboardCache = new Bitmap(tile.Width, tile.Height,
> PixelFormat.Format24bppRgb);
> 	GdiDrawer.DrawTile(this.tileClipboardCache, 0, 0, tile);
> }
> else
> {
> 	this.tileClipboardCache = (Bitmap)tile.Bitmap.Clone();
> }
> 
> 
> Alan McGovern-2 wrote:
>> 
>> Hey,
>> 
>> Well, if there's a bug then please try to reduce the testcase as much as
>> possible before submitting it. If you can't it's still worth filing a bug
>> and giving as much detail as you can.
>> 
>> If its working on .NET but not Mono that's not a good sign. I was
>>> afraid of something like this.
>> 
>> 
>> If there is an issue with a specific method, there are generally other
>> ways
>> of accomplishing exactly the same task. Sometimes all you need to do is
>> use
>> a different overload of the same method. For example here are two
>> alternate
>> methods of copying a bitmap, both of which are probably higher
>> performance
>> and both are definitely less bug prone:
>> 
>> http://msdn.microsoft.com/en-us/library/aa457087.aspx
>> 
>> So if you do encounter any issues, please file bug reports so they can be
>> dealt with for the next release.
>> 
>> Alan.
>> 
>>>
>>>
>>>
>>> Stifu wrote:
>>> >
>>> > I found a certain GDI+ bug recently, and I *think* it's related to
>>> > LockBits(). I'm not sure, and didn't report the bug as I couldn't make
>>> a
>>> > reduced test case yet. However, if you're interested, I can send you
>>> my
>>> > not-so-reduced test case so you can have a look.
>>> >
>>> > But to sum things up: I have a Bitmap, try to clone it, and the cloned
>>> > Bitmap is all black... while this works fine with .NET.
>>> >
>>> >
>>> > LKeene wrote:
>>> >>
>>> >> Hello all, I have a general question regarding the use of LockBits()
>>> (in
>>> >> GDI+) for reading/writing to a bitmap.  I'm using Mono 2.2 and am
>>> >> targeting Windows, OSX and Linux. Any current issues concerning the
>>> use
>>> >> of LockBits()/UnlockBits() I should be aware of? Any nasty buggies I
>>> >> should be on the lookout for? I found a few posts pertaining to this
>>> but
>>> >> they're not very current.
>>> >>
>>> >> Thanks eveyone.
>>> >>
>>> >> -L
>>> >>
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/LockBits%28%29-on-Mono-2.2--tp22611389p22611603.html
>>> Sent from the Mono - General mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> Mono-list maillist  -  Mono-list at lists.ximian.com
>>> http://lists.ximian.com/mailman/listinfo/mono-list
>>>
>> 
>> _______________________________________________
>> Mono-list maillist  -  Mono-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-list
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/LockBits%28%29-on-Mono-2.2--tp22611389p22621824.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list