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

New Post: WritableBitmap with wrong colors

$
0
0
Hi,

I have the same problem. Seems to be related to 8bit png's. Because 32 bit works fine.
Have you found any solution to this problem?

Thanks.

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.

Created Unassigned: AAWidthLine IndexOutOfRange [22063]

$
0
0
WriteableBitmapEx Version 1.5.0, WinRT Windows running on W10

The following code produces IndexOutOfRangeException
bitmap extent [w=1737, h=3855], color is black FF000000

int height = context.Bitmap.PixelHeight; // = 1737
int width = context.Bitmap.PixelWidth; // = 3855
!==> context.Bitmap.DrawLineAa(0, height - 1, width / 2, height - 1, color, 2);

at Windows.UI.Xaml.Media.Imaging.WriteableBitmapExtensions.AAWidthLine(Int32 width, Int32 height, BitmapContext context, Single x1, Single y1, Single x2, Single y2, Single lineWidth, Int32 color)
at Windows.UI.Xaml.Media.Imaging.WriteableBitmapExtensions.DrawLineAa(WriteableBitmap bmp, Int32 x1, Int32 y1, Int32 x2, Int32 y2, Color color, Int32 strokeThickness)

Commented Unassigned: AAWidthLine IndexOutOfRange [22063]

$
0
0
WriteableBitmapEx Version 1.5.0, WinRT Windows running on W10

The following code produces IndexOutOfRangeException
bitmap extent [w=1737, h=3855], color is black FF000000

int height = context.Bitmap.PixelHeight; // = 1737
int width = context.Bitmap.PixelWidth; // = 3855
!==> context.Bitmap.DrawLineAa(0, height - 1, width / 2, height - 1, color, 2);

at Windows.UI.Xaml.Media.Imaging.WriteableBitmapExtensions.AAWidthLine(Int32 width, Int32 height, BitmapContext context, Single x1, Single y1, Single x2, Single y2, Single lineWidth, Int32 color)
at Windows.UI.Xaml.Media.Imaging.WriteableBitmapExtensions.DrawLineAa(WriteableBitmap bmp, Int32 x1, Int32 y1, Int32 x2, Int32 y2, Color color, Int32 strokeThickness)
Comments: ** Comment from web user: teichgraf **

Thanks for pointing this out. Can you also repro it with a different size like 1738 x 3856?
Also, it would be helpful and increase the chance of a faster resolve if you attach a sample sln.

Created Unassigned: DrawLineAa causes AccessViolationException [22105]

$
0
0
I have a WriteableBitmap of Width 512, Height 480 but I believe this problem happens on any WriteableBitmap. When I draw a line such as 0,480 to 500,480 with a stroke thickness greater than 1, I get the exception. Also for x1,479 to x2,479 where x1 and x2 are reasonable. Using y1 not equal y2 prevents the exception. I'm using version 1.50 on Windows 10, VS Community 2015.

Created Unassigned: Could not install package WriteableBitmapEx because of "project that targets 'native,Version=v0.0'" [22221]

$
0
0
I am using WriteableBitmap on Windows Component Project (C++/CX) and want to include the WriteableBitmapEx for drawing like GDI+.
But, I cannot install this lib over NuGet. The error that I got is:
----------------------------------------------------
PM> Install-Package WriteableBitmapEx
Attempting to gather dependencies information for package 'WriteableBitmapEx.1.5.0' with respect to project 'base_utils\libUtils', targeting 'native,Version=v0.0'
Attempting to resolve dependencies for package 'WriteableBitmapEx.1.5.0' with DependencyBehavior 'Lowest'
Resolving actions to install package 'WriteableBitmapEx.1.5.0'
Resolved actions to install package 'WriteableBitmapEx.1.5.0'
Install failed. Rolling back...
Package 'WriteableBitmapEx.1.5.0 : ' does not exist in project 'libUtils'
Package 'WriteableBitmapEx.1.5.0 : ' does not exist in folder 'E:\PerforceData\1716\SPen5.0_UWP\SDK_UWP\build\packages'
Install-Package : Could not install package 'WriteableBitmapEx 1.5.0'. You are trying to install this package into a project that targets 'native,Version=v0.0', but the package does not contain any assembly references or content files that are compatible with
that framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package WriteableBitmapEx
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
----------------------------------------------------
Has anybody got this problem before? And how can you comeover to it?

Closed Unassigned: Could not install package WriteableBitmapEx because of "project that targets 'native,Version=v0.0'" [22221]

$
0
0
I am using WriteableBitmap on Windows Component Project (C++/CX) and want to include the WriteableBitmapEx for drawing like GDI+.
But, I cannot install this lib over NuGet. The error that I got is:
----------------------------------------------------
PM> Install-Package WriteableBitmapEx
Attempting to gather dependencies information for package 'WriteableBitmapEx.1.5.0' with respect to project 'base_utils\libUtils', targeting 'native,Version=v0.0'
Attempting to resolve dependencies for package 'WriteableBitmapEx.1.5.0' with DependencyBehavior 'Lowest'
Resolving actions to install package 'WriteableBitmapEx.1.5.0'
Resolved actions to install package 'WriteableBitmapEx.1.5.0'
Install failed. Rolling back...
Package 'WriteableBitmapEx.1.5.0 : ' does not exist in project 'libUtils'
Package 'WriteableBitmapEx.1.5.0 : ' does not exist in folder 'E:\PerforceData\1716\SPen5.0_UWP\SDK_UWP\build\packages'
Install-Package : Could not install package 'WriteableBitmapEx 1.5.0'. You are trying to install this package into a project that targets 'native,Version=v0.0', but the package does not contain any assembly references or content files that are compatible with
that framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package WriteableBitmapEx
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
----------------------------------------------------
Has anybody got this problem before? And how can you comeover to it?
Comments: The lib is not built to be used for WinMD, therefore C# only at this point. For C++ I'd recommend other libs.

Created Unassigned: DrawRectangle clipping and pixbuffer check [22244]

$
0
0
__DrawRectangle__ misbehaves with respect to the following issues
* it is easily possible to get WriteableBitmap with Width, Height not matching pixel buffer. For example when loading a bitmap from stream one has first to specify its size which can differ from that stored in the stream. Performing pixel operation in such case causes AccessViolation
* for x, y coordinates < 0 they are set to 0 which causes an unwanted edge to be drawn
* the same is true for coordinates exceeding the other bounds, the edges are adjusted and painted which may not be the expected behavior

Attached you can find an implementation of __DrawRectangleClip__ which behaves correct with respect to the points mentioned above. You may as well replace the erroneous implementation with this one.

Regards
Miroslaw

Commented Unassigned: AAWidthLine IndexOutOfRange [22063]

$
0
0
WriteableBitmapEx Version 1.5.0, WinRT Windows running on W10

The following code produces IndexOutOfRangeException
bitmap extent [w=1737, h=3855], color is black FF000000

int height = context.Bitmap.PixelHeight; // = 1737
int width = context.Bitmap.PixelWidth; // = 3855
!==> context.Bitmap.DrawLineAa(0, height - 1, width / 2, height - 1, color, 2);

at Windows.UI.Xaml.Media.Imaging.WriteableBitmapExtensions.AAWidthLine(Int32 width, Int32 height, BitmapContext context, Single x1, Single y1, Single x2, Single y2, Single lineWidth, Int32 color)
at Windows.UI.Xaml.Media.Imaging.WriteableBitmapExtensions.DrawLineAa(WriteableBitmap bmp, Int32 x1, Int32 y1, Int32 x2, Int32 y2, Color color, Int32 strokeThickness)
Comments: ** Comment from web user: mneumann **

I've reproduced it with the following parameter / call:
DrawLineAa(WriteableBitmap(W:2000 x H:1324), 304, 1324, 225, 1324, #FF0000FF, 5)

I see that the y1, y2 are outside the bitmap. However, I expect the line to be properly clipped
or as the second best solution an informative exception to be thrown.
Without source code I was only guessing and never came behind the cause.
```
Method AADrawLine()
{
...
if (y1 == y2)
{
...
// x = 225
// y = 1324
// w = 2000
// buffer.Length = 2648000
// y * width + x = 2648225
// it looks like it goes one line down outside of the bitmap
d = buffer[y * width + x]; // crash here
}
}
```

New Post: Issue with WriteableBitmapEx.Blit API

$
0
0
We are using WriteableBitmapEx library (version - 1.5.0).
From this library, Blit API is used to merge source writeablebitmap to the destination writeablebitmap destination.
This Blit() API is taking 60-100 seconds to execute, which is resulting very slow performance.

Code snippet for reference :
Rect srcRect = new Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight);
Rect destRect = new Rect((frame.PixelWidth - bitmap.PixelWidth) / 2, (frame.PixelHeight - bitmap.PixelHeight) / 2, bitmap.PixelWidth, bitmap.PixelHeight);
frame.Blit(destRect, bitmap, srcRect, Windows.UI.Xaml.Media.Imaging.WriteableBitmapExtensions.BlendMode.Mask); //where frame and bitmap is writeablebitmap object.

Observations:
Issue is observed on Phone only.
If we run the app in debug mode, API takes around 5 seconds.
If we run the app in release mode, API takes around 60 to 100 seconds. Sometime more than this.

Expectations:
We are expecting your suggestions on this for an alternate solution or any modifications to be made to correct this API work.

New Post: Issue with WriteableBitmapEx.Blit API

$
0
0
First of all think about how you phrase your expectations for a free open source project where we as contributors put our free time for free into it to make a product that can be used commercially without any royalties.

What you observe is likely a side effect of .NET Native since it's not observed in Debug mode. The NET Native Team has a fix for this that is available in a preview build. Nothing we can do.

New Post: Issue with WriteableBitmapEx.Blit API

Created Unassigned: SetPixel(x,y,color) alpha misbehaves [22299]

$
0
0
I wrote a simple piece of code that changes color of icons while keeping the pixels opacity. However SetPixel(x,y,color) and SetPixel(x,y,a,color) and .ForEach((x, y, color) =>{} misbehaved as transparent pixels became much darker. SetPixel(x,y,a,r,g,b) however behaves correctly.

Sample Code
```
Brush tint = Brushes.LightGreen;
WriteableBitmap wBmp = new WriteableBitmap(bmpSrc as BitmapSource);

//This misbehaves
wBmp.ForEach((x, y, color) =>
{
Color col = wBmp.GetPixel(x, y);
Color col2 = Color.FromArgb(col.A,
((Color)tint.GetValue(SolidColorBrush.ColorProperty)).R,
((Color)tint.GetValue(SolidColorBrush.ColorProperty)).G,
((Color)tint.GetValue(SolidColorBrush.ColorProperty)).B);
return col2;
}
);
//this works
for (int x = 0; x < bmpSrc.PixelWidth; x++)
{
for (int y = 0; y < bmpSrc.PixelHeight; y++)
{
Color col = wBmp.GetPixel(x, y);

col.B = ((Color)tint.GetValue(SolidColorBrush.ColorProperty)).B;
col.R = ((Color)tint.GetValue(SolidColorBrush.ColorProperty)).R;
col.G = ((Color)tint.GetValue(SolidColorBrush.ColorProperty)).G;
//color.Alpha = ((Color)tint.GetValue(SolidColorBrush.ColorProperty)).A;

//Only this version of SetPixel Works
wBmp.SetPixel(x, y, col.A, col.R, col.G, col.B);
---------------------------------------------------------------------------------
//This Does Not Work Either
// wBmp.SetPixel(x, y, col.A,((Color)tint.GetValue(SolidColorBrush.ColorProperty)));
---------------------------------------------------------------------------------
}
}
```

New Post: DrawString method implementation

$
0
0
Is this going to get integrated into the next release?
Would love to have it as a nuget package

New Post: How to draw by DrawLinePenned?

$
0
0
I want to add thickness to a line.
I use C#, WPF.
I tried, but it doesn't work:
            WriteableBitmap writeableBitmap = BitmapFactory.New(500, 500);
            writeableBitmap.DrawLinePenned(10, 10, 50, 50, ?);

New Post: WriteableBitmap "out of memory exception" or COMException 88980003

$
0
0
Were you ever able to find fixes for the memory stuff?

I believe this is .NET 4.5 and up only, but putting
<runtime>
  <gcAllowVeryLargeObjects enabled="true" />
</runtime>
into your App.config will help depending on what exactly you're doing. Basically on 64-bit platforms, enables arrays that are greater than 2 gigabytes (GB) in total size, which may solve certain issues (it did with me but that was because I was using arrays along with WriteableBitmapEx).

New Post: WriteableBitmap "out of memory exception" or COMException 88980003

$
0
0

No, I was not. I basically gave up on using WriteableBitmapEx class.

Thanks,

Rick


On 8/18/2016 6:00 AM, Scusemua wrote:

From: Scusemua

Were you ever able to find fixes for the memory stuff?

I believe this is .NET 4.5 and up only, but putting
<runtime><gcAllowVeryLargeObjects enabled="true" /></runtime>
into your App.config will help depending on what exactly you're doing. Basically on 64-bit platforms, enables arrays that are greater than 2 gigabytes (GB) in total size, which may solve certain issues (it did with me but that was because I was using arrays along with WriteableBitmapEx).

New Post: writeablebitmapex FillEllipseCentered with center out of boundary

$
0
0
I have writeablebitmap with width and height equal to 580, i need to draw a circle in it. So i will use bmp.FillEllipseCentered(290,290,290,290,color);

I need to zoom this circle by scaling factor 2, say the radius will be 290 *2 = 580, so that i will move the scroll bar and i will be able to see the curves of the circle by changing the center position.
bmp.FillEllipseCentered(580-x,580-y,580,580,color);

When i zooming again, circle is not coming i was getting some lines at the end region. Is there any way to achieve this zoom in this fillellipsecentered by scalingfactor.
bmp.FillEllipseCentered(1160-x,1160-y,1160,1160,color);.. i was not getting circle or curves

Created Unassigned: writeablebitmapex FillEllipseCentered with center out of boundary [22517]

$
0
0
I have writeablebitmap with width and height equal to 580, i need to draw a circle in it. So i will use bmp.FillEllipseCentered(290,290,290,290,color);

I need to zoom this circle by scaling factor 2, say the radius will be 290 *2 = 580, so that i will move the scroll bar and i will be able to see the curves of the circle by changing the center position.
bmp.FillEllipseCentered(580-x,580-y,580,580,color);

When i zooming again, circle is not coming i was getting some lines at the end region. Is there any way to achieve this zoom in this fillellipsecentered by scalingfactor.
bmp.FillEllipseCentered(1160-x,1160-y,1160,1160,color);.. i was not getting circle or curves

Created Unassigned: Create Polygon with color of border is different from inside [22549]

$
0
0
I would like to draw a polygon that border's color is not same as inside's color as below:
![Image](https://ibb.co/bPYdnF)

I think this it can be achieved by combining FillPolygon and DrawPolygon (create border).
However, DrawPolygon is not available in WriteableBitmapEx.

I tried to use DrawPolyline, but the result is not good, the polygon created by FillPolygon and DrawPolyline are not same.

Do you have any suggestion for me?
Thank you very much!
Viewing all 360 articles
Browse latest View live


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