Quantcast
Channel: WriteableBitmapEx
Viewing all articles
Browse latest Browse all 360

Commented Feature: FillRectangle incorrectly includes right/bottom [21276]

$
0
0
If you call FillRectangle and pass a rectangle with width 1 and height 1, it instead fills an area 2 pixels wide and 2 pixels high.

It appears that WriteableBitmapEx's FillRectangle is including x2 and y2 in its rectangle. This is inconsistent with both System.Drawing and WPF, as well as every other graphics library I've ever used (GDI, GDI+, Delphi's TCanvas, ImageMagick, PyGame, etc.) FillRect calls typically do not fill the right-most column or the bottom-most row. That's because rectangle coordinates typically represent the grid lines between pixels, and that's because the math is far, far easier that way. (Raymond Chen has a good explanation at http://blogs.msdn.com/b/oldnewthing/archive/2004/02/18/75652.aspx.)

Repro (using the latest NuGet release, 1.0.12.0):

var bitmap = BitmapFactory.New(2, 2);
// Should fill an area (1 - 0) pixels wide and (1 - 0) pixels high
bitmap.FillRectangle(0, 0, 1, 1, Colors.Red);
MyImage.Source = bitmap;

Expected: a 2x2 bitmap with one red pixel in the top left.

Actual: a 2x2 bitmap completely filled with red.
Comments: ** Comment from web user: JeroenWalter **

This is solved incorrectly.
See https://github.com/teichgraf/WriteableBitmapEx/issues/5

As it is now it is never possible to fill the right side or the bottom side of the bitmap.

It would be better to change the parameters of FillRectangle from x1,y1,x2,y2 to x,y,width,height.


Viewing all articles
Browse latest Browse all 360

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>