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

Created Release: WriteableBitmapEx 1.5.0 (Mar 31, 2015)

$
0
0
!This is the final version 1.5.0 of WriteableBitmapEx with WPF, Silverlight, WinRT Windows and Windows Phone XAML and Silverlight support
  • Supports a variety of versions including Windows 10 UAP, Windows 8, 8.1, Windows Phone WinRT and Silverlight 7, 8, 8.1
  • Added lots of contributions including DrawLine with variable thickness, penning, improved anti-aliasing and Wu's anti-aliasing algorithm.
  • Added usage of CohenSutherlandLineClip for DrawLineAa and DrawLine
  • Added support for alpha blended filled shapes and adapted the FillSample for WPF
  • Added FillPolygonsEvenOdd() which uses the even-odd algorithm to fill complex polygons with more than one closed outline like for the letter O
  • Added AdjustBrightness(), AdjustContrast() and AdjustGamma() methods
  • Added Gray() method which returns the gray scaled version the bitmap
  • Fixed bug in Blit Alpha code for WPF when source format is not pre-multiplied alpha
  • Fixed bug #21778 where FromStream for WPF needs to be called inside Init scope
  • Fixed issue with IndexOutOfRangeEx in DrawLine method
  • Fixed Invalidate for Silverlight BitmapContext.Dispose
  • Fixed regression issue with alpha blending for Blit for non-WinRT
  • Fixed many more reported issues https://writeablebitmapex.codeplex.com/workitem/list/basic

Contains the WriteableBitmapEx binaries for Windows Phone, WPF, WinRT Windows Store XAML and Silverlight. Download the source for the samples.

Blog posts with more details:
http://kodierer.blogspot.com/2015/03/staying-alive-writeablebitmapex-15.html

Source code checked in, #113583

$
0
0
* Updated NuGet for 1.5.0.0 release

Created Unassigned: WriteableBitmaps from BitmapImages located outside of Assets folder [21798]

$
0
0
Hello. Do these methods only work on images stored in the Assets folder of the app? Currently I have an BitmapImage that is set using a RandomAccessStream rather than a Uri, then found out this wasn't possible as it only works for certain types of bitmaps (Uri specified to web or local app directory). So as it worked for images in my Assets folder using the Uri scheme ms-appx I had other images in /LocalCache instead of Assets but I couldn't get it to work. The Uri shows as below.

Uri = file:///C:/Data/Users/DefApps/APPDATA/Local/Packages/MYAPPFOLDER/LocalCache/MyImage.png

According to msdn http://blogs.windows.com/buildingapps/2014/06/19/common-questions-and-answers-about-files-and-app-data-part-1-app-data/

localcache uses the Uri scheme ms-appdata:///localcache, so I tried this as well but it has failed and the WriteableBitmapExtension tools throw an error

WinRT information: 'uri': Only http, https and ftp schemes are allowed.
Additional information: The parameter is incorrect.

It would be nice if more support was added for files outside of the AppData folder using the one Uri scheme and you could use files anywhere (so long as your app has the required permission). I even tried specifying the absolute path as shown in the first Uri in my post and though the image loads in my app the Bitmap tools failed to do anything with the image.

All I am trying to do is resize a bitmapimage and get the color and it seems very difficult using the native api, I was hoping this one would help but so far I have not been able to manage.
public static async Task<Color> GetColorFromBitmap(BitmapImage image)
{
try
{
WriteableBitmap WriteableImage = await WriteableBitmapFromBitmapImageExtension.FromBitmapImage(image);
WriteableImage = WriteableBitmapExtensions.Resize(WriteableImage, 1, 1, WriteableBitmapExtensions.Interpolation.Bilinear);

Color PixelColor = WriteableImage.GetPixel(0, 0);
return PixelColor;
}
catch (Exception ex)
{
return Colors.Black;
}
}
Instead of trying to convert all BitmapImages (whether set as Uri or set using SetSourceAsync(RandomAccessStream)) I instead just tried to create the WriteableBitmap from the start, and though it was created so the first line in the code above was not necessary, the second line failed for the resize on the WriteableBitmaps that were created using a Bitmap that was set using a RandomAccessStream.

Can anyone advise how I can get an image in my app LocalCache folder resized :) Thanks for your time and help in advance!

New Post: Writeablebitmap get object drawn

$
0
0
Is there any way to get object drawn by writeablebitmapex in windows phone 8.
In my case, i want to get eclipse which drawn previously to delete or move its. For now, i add eclipse by this code:
        int ansX1 = Convert.ToInt32(left-10);
        int ansX2 = Convert.ToInt32(left + a.ActualWidth + 10);
        int ansY1 = Convert.ToInt32(top-10);
        int ansY2 = Convert.ToInt32(top + a.ActualHeight+10);

        writeableBmp.DrawEllipse(ansX1, ansY1, ansX2, ansY2, Colors.Black);
Thanks

Source code checked in, #113740

$
0
0
* Fixed bug with WPF Dispose and DecrementRefCount

New Post: RotateFree on 48BPP image

$
0
0
Hi all,
I note that WriteableBitmapEx will corrupt a bitmap if rotating an image that is 48 bit.

I really need this to work, so I took a look at the source code. I can see some hard coded references to numbers like 8 and 24, but to be honest I can't really see how the method even works.

Is there some kind of complexity I'm not seeing in how rotating a 48 bit image is a lot different to a 32 bit one?

Thanks

Garry

Created Unassigned: WPF WriteableBitmapExtensions.Resize incorrect alpha value in the final picture [21828]

$
0
0
For source bitmap with alpha channel ```WriteableBitmapExtensions.Resize(BitmapContext srcContext, int widthSource, int heightSource, int width, int height, Interpolation interpolation)``` returns incorrect alpha values in the result bitmap.

This method uses ```WriteableBitmapExtensions.Resize(BitmapContext srcContext, int widthSource, int heightSource, int width, int height, Interpolation interpolation)``` to resize bitmap.

```WriteableBitmapExtensions.Resize(BitmapContext srcContext, int widthSource, int heightSource, int width, int height, Interpolation interpolation)``` returns bitmap in *bgra32* pixel-format.

Then ```WriteableBitmapExtensions.Resize(this WriteableBitmap bmp, int width, int height, Interpolation interpolation)``` method uses BitmapFactory.New(width, height) to create result bitmap.
```C#
var result = BitmapFactory.New(width, height);
```
```BitmapFactory.New(width, height)``` creates *pbgra32* bitmap.
Incorrect alpha value in in the final picture as result.

New Post: From... methods

$
0
0
Many thanks for a great library!

I am not sure if this has been discussed before, but one thing I find a bit non-intuitive with the library are the FromContent, FromStream etc. methods in the WriteableBitmapConvertExtensions.cs file.

One example is FromStream that in one overload has the following signature:
public static WriteableBitmap FromStream(this WriteableBitmap bmp, Stream stream);
Upon exit, a newWriteableBitmap is created, and this same object is also returned from the method.

I would find it more intuitive if this was not implemented as an extension method. Instead, I would recommend to move all the From methods to BitmapFactory and remove the extension argument. For example:
public static class BitmapFactory {
  ...
  public static WriteableBitmap FromStream(Stream stream) { ... }
  ...
}
The code can remain practically the same, only that the extension argument assignment in each method is removed, e.g. delete statements like this from the moved methods:
bmp = new WriteableBitmap(/* BitmapImage */ bmpi);
What do you think?

Best regards,
Anders @ Cureos

New Post: From... methods

$
0
0
Just to clarify, this concerns the methods loading a WriteableBitmap from resources. The FromByteArray methods are not concerned, since the incoming bitmap is required with these methods.

I am finalizing a patch to illustrate my point, please stay tuned :-)

Patch Uploaded: #17504

$
0
0

cureos has uploaded a patch.

Description:
This patch illustrates how the WriteableBitmap initialization methods from resources (Content, Stream etc.) can be moved from WriteableBitmapConvertExtensions to BitmapFactory for (in my opinion) a more intuitive API.

The methods are changed from extension methods to regular static methods, returning the WriteableBitmap that is created inside the method.

The issue was initially raised in the discussion forum here: https://writeablebitmapex.codeplex.com/discussions/637453

I have not removed the original extension methods, but I have decorated them with an [Obsolete] attribute.

As a proof-of-concept, I have updated the samples where these convert extension methods were previously used.

Since several of the source code files had SVN properties image/png, I failed to create a decent SVN patch. I have therefore copied only the changed files in their entirety, and placed them in corresponding folders in the compressed zip archive.

New Post: From... methods

$
0
0
I have now added a patch with ID 17504 to support this proposal.

Created Unassigned: SetPixel(x, y, a, r, g, b) overload is bugged [21874]

$
0
0
Hi, I've just lost 2 hours search a bug in an algorithm and finally found that the problem is SetPixel(x, y, a, r, g, b) overload. Seems that there is a lost of precision that in some cases transform the color in a total different value. Using SetPixel(x, y, color) there are no problems

Created Unassigned: Resize throws System.AccessViolationException [21885]

$
0
0
I am trying to resample ~6MB images in a Universal App using WriteableBitmapEx. After loading the image using SetSource() I call Resize(NearestNeighbor), which always throw a System.AccessViolationException involving {System.Collections.ListDictionaryInternal}.

Here is additional information regarding the exception:

System.AccessViolationException was unhandled by user code
HResult=-2147467261
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=WriteableBitmapEx.WinRT
StackTrace:
at Windows.UI.Xaml.Media.Imaging.BitmapContext.CopyPixels()
at Windows.UI.Xaml.Media.Imaging.BitmapContext..ctor(WriteableBitmap writeableBitmap, ReadWriteMode mode)
at Windows.UI.Xaml.Media.Imaging.WriteableBitmapExtensions.Resize(WriteableBitmap bmp, Int32 width, Int32 height, Interpolation interpolation)
<snip>
InnerException:

Any help towards solving this will be greatly appreciated.

Updated Wiki: Home

$
0
0

Description

The WriteableBitmapEx library is a collection of extension methods for the WriteableBitmap. The WriteableBitmap class is available for Windows Phone, WPF, WinRT Windows Store XAML, UWP and Silverlight and allows the direct manipulation of a bitmap and could be used to generate fast procedural images by drawing directly to a bitmap. The WriteableBitmap API is very minimalistic and there's only the raw Pixels array for such operations. The WriteableBitmapEx library tries to compensate that with extensions methods that are easy to use like built in methods and offer GDI+ like functionality. The library extends the WriteableBitmap class with elementary and fast (2D drawing) functionality, conversion methods and functions to combine (blit) WriteableBitmaps.
The extension methods are grouped into different CS files with a partial class. It is possible to include just a few methods by using the specific source CS files directly or all extension methods through the built library assembly.

Available as NuGet package.

WriteableBitmapEx was also ported to Windows Embedded.

See the Issue Tracker for a list of features that will be added in the future.

wbx_announcement.png

Features

GDI+ like drawing functionality for the WriteableBitmap.
Support for Windows Phone Silverlight, Windows Phone WinRT, desktop Silverlight, WPF, Windows 8/8.1 WinRT XAML and Windows 10 UWP.
  • Base
    • Support for the Color structure (alpha premultiplication will be performed)
    • Also overloads for faster int32 as color (assumed to be already alpha premultiplied)
    • SetPixel method with various overloads
    • GetPixel method to get the pixel color at a specified x, y coordinate
    • Fast Clear methods
    • Fast Clone method to copy a WriteableBitmap
    • ForEach method to apply a given function to all pixels of the bitmap
  • Transformation
    • Crop method to extract a defined region
    • Resize method with support for bilinear interpolation and nearest neighbor
    • Rotate in 90° steps clockwise and any arbitrary angle
    • Flip vertical and horizontal
  • Shapes
    • Fast line drawing algorithms including various anti-aliased algorithm
    • Variable stroke thickness and penned / stamp lines
    • Ellipse, polyline, quad, rectangle and triangle
    • Cubic Beziér, Cardinal spline and closed curves
  • Filled shapes
    • Fast ellipse and rectangle fill method
    • Triangle, quad, simple and complex polygons
    • Beziér and Cardinal spline curves
  • Blitting
    • Different blend modes including alpha, additive, subtractive, multiply, mask and none
    • Optimized fast path for non blended blitting
  • Filtering
    • Convolution, Blur
    • Brightness, contrast, gamma adjustments
    • Gray/brightness, invert
  • Conversion
    • Convert a WriteableBitmap to a byte array
    • Create a WriteableBitmap from a byte array
    • Create a WriteableBitmap easily from the application resource or content
    • Create a WriteableBitmap from an any platform supported image stream
    • Write a WriteableBitmap as a TGA image to a stream
    • Separate extension method to save as a PNG image. Download here
  • Windows Phone specific methods
    • Save to media library and the camera roll
  • External Code

Live samples

Samples that come with the WriteableBitmapEx source code in action:
  • The Shapes sample includes various scenarios where different shapes are drawn. By default a little demo is shown called "Breathing Flower". Basically different sized circles rotating around a center ring are generated. The sample also contains a static page showing some of the possible shapes.
  • The Fill sample starts with a demo that animates the Cardinal spline's tension of the FillCurveClosed method, plus some random animated filled ellipses. The sample also contains a static page showing some of the possible filled shapes.
  • The Curve sample demonstrates the Beziér and Cardinal spline methods. The sample starts with a demo animation that uses the Cardinal spline DrawCurve method to draw an artificial plant that grows procedurally. The other part of the sample is interactive and allows to draw and manipulate Beziér and Cardinal splines with the mouse. See this blog post for further information.
  • The Blit sample combines WriteableBitmaps and shows a neat particle effect.
Video of the Windows Phone Interactive Curve Sample.

External resources:
Adam Kinney made a great sample that uses the WriteableBitmapEx library to dynamically apply a torn weathered effect to a photo.
Erik Klimczak from Calrity Consulting wrote a very good blog post about Advanced Animation: Animating 15,000 Visuals in Silverlight. He uses the WriteableBitmapEx to get the best performance.
Peter Bromberg wrote a great article called Silverlight 4 Martin Fractals with WriteableBitmapEx.

Performance!

The WriteableBitmapEx methods are much faster than the XAML Shape subclasses. For example, the WriteableBitmapEx line drawing approach is more than 20-30 times faster as the Silverlight Line element. So if a lot of shapes need to be drawn and anti-aliasing or other SIlverlight Shape properties are not needed, the WriteableBitmapEx methods are the right choice.

Easy to use!

// Initialize the WriteableBitmap with size 512x512 and set it as source of an Image control
WriteableBitmap writeableBmp = BitmapFactory.New(512, 512);
ImageControl.Source = writeableBmp;
writeableBmp.GetBitmapContext();

// Load an image from the calling Assembly's resources only by passing the relative path
writeableBmp = BitmapFactory.New(1, 1).FromResource("Data/flower2.png");

// Clear the WriteableBitmap with white color
writeableBmp.Clear(Colors.White);

// Set the pixel at P(10, 13) to black
writeableBmp.SetPixel(10, 13, Colors.Black);

// Get the color of the pixel at P(30, 43)
Color color = writeableBmp.GetPixel(30, 43);

// Green line from P1(1, 2) to P2(30, 40)
writeableBmp.DrawLine(1, 2, 30, 40, Colors.Green);

// Line from P1(1, 2) to P2(30, 40) using the fastest draw line method with the color as integerint[] pixels = writeableBmp.Pixels;
int w = writeableBmp.PixelWidth;
int h = writeableBmp.PixelHeight;
WriteableBitmapExtensions.DrawLine(pixels, w, h, 1, 2, 30, 40, myIntColor);

// Blue anti-aliased line from P1(10, 20) to P2(50, 70) with a stroke thickness of 5
writeableBmp.DrawLineAa(10, 20, 50, 70, Colors.Blue, 5);

// Black triangle with the points P1(10, 5), P2(20, 40) and P3(30, 10)
writeableBmp.DrawTriangle(10, 5, 20, 40, 30, 10, Colors.Black);

// Red rectangle from the point P1(2, 4) that is 10px wide and 6px high
writeableBmp.DrawRectangle(2, 4, 12, 10, Colors.Red);

// Filled blue ellipse with the center point P1(2, 2) that is 8px wide and 5px high
writeableBmp.FillEllipseCentered(2, 2, 8, 5, Colors.Blue);

// Closed green polyline with P1(10, 5), P2(20, 40), P3(30, 30) and P4(7, 8)int[] p = newint[] { 10, 5, 20, 40, 30, 30, 7, 8, 10, 5 };
writeableBmp.DrawPolyline(p, Colors.Green);

// Cubic Beziér curve from P1(5, 5) to P4(20, 7) with the control points P2(10, 15) and P3(15, 0)
writeableBmp.DrawBezier(5, 5, 10, 15, 15, 0, 20, 7,  Colors.Purple);

// Cardinal spline through the points P1(10, 5), P2(20, 40) and P3(30, 30) with a tension of 0.5int[] pts = newint[] { 10, 5, 20, 40, 30, 30};
writeableBmp.DrawCurve(pts, 0.5,  Colors.Yellow);

// A filled Cardinal spline through the points P1(10, 5), P2(20, 40) and P3(30, 30) with a tension of 0.5
writeableBmp.FillCurveClosed(pts, 0.5,  Colors.Green);

// Blit a bitmap using the additive blend mode at P1(10, 10)
writeableBmp.Blit(new Point(10, 10), bitmap, sourceRect, Colors.White, WriteableBitmapExtensions.BlendMode.Additive);

// Override all pixels with a function that changes the color based on the coordinate
writeableBmp.ForEach((x, y, color) => Color.FromArgb(color.A, (byte)(color.R / 2), (byte)(x * y), 100));

// Present the WriteableBitmap!
writeableBmp.Invalidate();

// Take snapshotvar clone = writeableBmp.Clone();

// Save to a TGA image stream (file for example)
writeableBmp.WriteTga(stream);

// Crops the WriteableBitmap to a region starting at P1(5, 8) and 10px wide and 10px highvar cropped = writeableBmp.Crop(5, 8, 10, 10);

// Rotates a copy of the WriteableBitmap 90 degress clockwise and returns the new copyvar rotated = writeableBmp.Rotate(90);

// Flips a copy of the WriteableBitmap around the horizontal axis and returns the new copyvar flipped = writeableBmp.Flip(FlipMode.Horizontal);

// Resizes the WriteableBitmap to 200px wide and 300px high using a bilinear interpolation methodvar resized = writeableBmp.Resize(200, 300, WriteableBitmapExtensions.Interpolation.Bilinear);

// Invalidate
writeableBmp.Dispose();

Additional Information

The WriteableBitmapEx library has its origin in several blog posts that also describe the implemenation and usage of some aspects in detail. The blog posts might be seen as the documentation.
WriteableBitmap Extension Methods introduced the SetPixel methods.
Drawing Lines - Silverlight WriteableBitmap Extensions II provided the DrawLine methods.
Drawing Shapes - Silverlight WriteableBitmap Extensions III brought the shape functionality (ellipse, polyline, quad, rectangle, triangle).
Convert, Encode And Decode Silverlight WriteableBitmap Data came with the byte array conversion methods and hows how to encode / decode a WriteableBitmap to JPEG.
Blitting and Blending with Silverlight’s WriteableBitmap provided the Blit functions.
WriteableBitmapEx - WriteableBitmap extensions now on CodePlex announced this project.
Quick and Dirty Output of WriteableBitmap as TGA Image provided the original TgaWrite function.
Rounder, Faster, Better - WriteableBitmapEx 0.9.0.0 announced version 0.9.0.0 and gives some further information about the curve sample.
Let it ring - WriteableBitmapEx for Windows Phone introtuced the WriteableBitmapEx version for the Windows Phone and a sample.
Filled To The Bursting Point - WriteableBitmapEx 0.9.5.0 announced version 0.9.5.0, has some information about the new Fill methods and comes with a nice sample.
One Bitmap to Rule Them All - WriteableBitmapEx for WinRT Metro Style announced version 1.0.0.0 and provides some background about the WinRT Metro Style version.

Support it

Donate

Credits

Rene Schulte started this project, maintains it and provided most of the code.
Dr. Andrew Burnett-Thompson proposed the portability refactoring, WPF port and much more beneficial functions.
Nikola Mihaylov (Nokola) made some optimizations on the DrawLine and DrawRectangle methods, provided the original TgaWrite and the anti-aliased line drawing function.
Bill Reiss wrote the Blit methods.
Adam Kinney added some Blending modes to the Blit method.
Colin Eberhardt contributed the ForEach method.
Steve Hawley proposed an optimization of the Clear(Color) method.
Liam Bateman suggested the Color Keying BlendMode.
Mattias Fagerlund suggested the convolution method.
Wout de Zeeuw optimized the DrawLine method by 15%.
Lachlan Keown fixed a bug in the Blit alpha blending.
John Ng San Ping added the AdjustBrightness, Contrast and Gray methods
Your name here? We are always looking for valuable contributions.

René Schulte wrote all the rest and coordinates this project.

Ohloh statistics

Created Unassigned: AdjustContrast Exceptions [21932]

$
0
0
I am trying to use the ContrastAdjust filter by tying a WPF Slider control to an image.

In the snippet below, the Value property of the slider is bound to the Contrast property in the ViewModel.
In addition ImageSource is a BitmapSource that the Image control's Source property is bound to.

public double Contrast
{
get { return _contrast; }
set
{
if ( value != _contrast )
{
_contrast = value;
OnPropertyChanged( "Contrast" );
}
CreateConvertedImage();
}
}

protected override void CreateConvertedImage()
{
if ( OriginalImageSource != null )
{
WriteableBitmap writeable = new WriteableBitmap( OriginalImageSource );
ImageSource = writeable.AdjustContrast( Contrast );
}
}

When I grab and drag the slider I get the following exception:

System.Runtime.InteropServices.COMException was unhandled by user code
HResult=-2003304445
Message=Exception from HRESULT: 0x88980003
Source=PresentationCore
ErrorCode=-2003304445
StackTrace:
at System.Windows.Media.Imaging.WriteableBitmap..ctor(Int32 pixelWidth, Int32 pixelHeight, Double dpiX, Double dpiY, PixelFormat pixelFormat, BitmapPalette palette)
at System.Windows.Media.Imaging.BitmapFactory.New(Int32 pixelWidth, Int32 pixelHeight) in d:\My Projects\Visual Studio 2013\Projects\FilterPlay\FilterPlay\Extensions\BitmapFactory.cs:line 47
at System.Windows.Media.Imaging.WriteableBitmapExtensions.AdjustContrast(WriteableBitmap bmp, Double level) in d:\My Projects\Visual Studio 2013\Projects\FilterPlay\FilterPlay\Extensions\WriteableBitmapFilterExtensions.cs:line 290
at FilterPlay.ContrastFilterViewModel.CreateConvertedImage() in d:\My Projects\Visual Studio 2013\Projects\FilterPlay\FilterPlay\ContrastFilterViewModel.cs:line 49
at FilterPlay.ContrastFilterViewModel.set_Contrast(Double value) in d:\My Projects\Visual Studio 2013\Projects\FilterPlay\FilterPlay\ContrastFilterViewModel.cs:line 32
InnerException:

Any help would be appreciated!

Thanks,

Rick B

Commented Unassigned: AdjustContrast Exceptions [21932]

$
0
0
I am trying to use the ContrastAdjust filter by tying a WPF Slider control to an image.

In the snippet below, the Value property of the slider is bound to the Contrast property in the ViewModel.
In addition ImageSource is a BitmapSource that the Image control's Source property is bound to.

public double Contrast
{
get { return _contrast; }
set
{
if ( value != _contrast )
{
_contrast = value;
OnPropertyChanged( "Contrast" );
}
CreateConvertedImage();
}
}

protected override void CreateConvertedImage()
{
if ( OriginalImageSource != null )
{
WriteableBitmap writeable = new WriteableBitmap( OriginalImageSource );
ImageSource = writeable.AdjustContrast( Contrast );
}
}

When I grab and drag the slider I get the following exception:

System.Runtime.InteropServices.COMException was unhandled by user code
HResult=-2003304445
Message=Exception from HRESULT: 0x88980003
Source=PresentationCore
ErrorCode=-2003304445
StackTrace:
at System.Windows.Media.Imaging.WriteableBitmap..ctor(Int32 pixelWidth, Int32 pixelHeight, Double dpiX, Double dpiY, PixelFormat pixelFormat, BitmapPalette palette)
at System.Windows.Media.Imaging.BitmapFactory.New(Int32 pixelWidth, Int32 pixelHeight) in d:\My Projects\Visual Studio 2013\Projects\FilterPlay\FilterPlay\Extensions\BitmapFactory.cs:line 47
at System.Windows.Media.Imaging.WriteableBitmapExtensions.AdjustContrast(WriteableBitmap bmp, Double level) in d:\My Projects\Visual Studio 2013\Projects\FilterPlay\FilterPlay\Extensions\WriteableBitmapFilterExtensions.cs:line 290
at FilterPlay.ContrastFilterViewModel.CreateConvertedImage() in d:\My Projects\Visual Studio 2013\Projects\FilterPlay\FilterPlay\ContrastFilterViewModel.cs:line 49
at FilterPlay.ContrastFilterViewModel.set_Contrast(Double value) in d:\My Projects\Visual Studio 2013\Projects\FilterPlay\FilterPlay\ContrastFilterViewModel.cs:line 32
InnerException:

Any help would be appreciated!

Thanks,

Rick B
Comments: ** Comment from web user: teichgraf **

This is not an issue with the lib. This is rather something for the discussion forums.
Anyway, make sure your OriginalImageSource instance is already initialized when you perform the operation. Check it's pixel width and height properties to make sure those are > 0.

Closed Unassigned: AdjustContrast Exceptions [21932]

$
0
0
I am trying to use the ContrastAdjust filter by tying a WPF Slider control to an image.

In the snippet below, the Value property of the slider is bound to the Contrast property in the ViewModel.
In addition ImageSource is a BitmapSource that the Image control's Source property is bound to.

public double Contrast
{
get { return _contrast; }
set
{
if ( value != _contrast )
{
_contrast = value;
OnPropertyChanged( "Contrast" );
}
CreateConvertedImage();
}
}

protected override void CreateConvertedImage()
{
if ( OriginalImageSource != null )
{
WriteableBitmap writeable = new WriteableBitmap( OriginalImageSource );
ImageSource = writeable.AdjustContrast( Contrast );
}
}

When I grab and drag the slider I get the following exception:

System.Runtime.InteropServices.COMException was unhandled by user code
HResult=-2003304445
Message=Exception from HRESULT: 0x88980003
Source=PresentationCore
ErrorCode=-2003304445
StackTrace:
at System.Windows.Media.Imaging.WriteableBitmap..ctor(Int32 pixelWidth, Int32 pixelHeight, Double dpiX, Double dpiY, PixelFormat pixelFormat, BitmapPalette palette)
at System.Windows.Media.Imaging.BitmapFactory.New(Int32 pixelWidth, Int32 pixelHeight) in d:\My Projects\Visual Studio 2013\Projects\FilterPlay\FilterPlay\Extensions\BitmapFactory.cs:line 47
at System.Windows.Media.Imaging.WriteableBitmapExtensions.AdjustContrast(WriteableBitmap bmp, Double level) in d:\My Projects\Visual Studio 2013\Projects\FilterPlay\FilterPlay\Extensions\WriteableBitmapFilterExtensions.cs:line 290
at FilterPlay.ContrastFilterViewModel.CreateConvertedImage() in d:\My Projects\Visual Studio 2013\Projects\FilterPlay\FilterPlay\ContrastFilterViewModel.cs:line 49
at FilterPlay.ContrastFilterViewModel.set_Contrast(Double value) in d:\My Projects\Visual Studio 2013\Projects\FilterPlay\FilterPlay\ContrastFilterViewModel.cs:line 32
InnerException:

Any help would be appreciated!

Thanks,

Rick B
Comments: Not an issue.

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

$
0
0
I am trying to use WriteableBitmapEx filter methods Adjust Brightness/Contrast/Gamma to adjust images in response to Slider control value changes and I am getting the above exceptions. I have tried to force garbage collection and release resources, but have not totally eliminated the exceptions. With my test app I can select the JPG image that I want to manipulate and the issue does seem to be a problem with larger files.

Can someone point me at a working example of how to do this?

Thanks,

Rick Burke

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

$
0
0
I am still unable to resolve the issue with memory leaks after calls the Writeablebitmap filter extensions. The leaks may not be in the extensions, but they make the extensions unusable.

As an aside... I was able to make significant performance improvements in every filter by using Parallel.For loops for processing. For example, I was able to reduce the time for a 3x3 Gaussian blur from 2.45 seconds to 0.67 seconds by making this simple change. My platform was a WPF desktop app.

The filter extensions all return a new WriteableBitmap. I will be trying a different approach that updates the Back Buffer of the original bitmap instead. Hopefully this will work around the leaking objects!

In the mean time, if anyone has any guidance I would be interested to hear it. That is if anyone actually reads this note (this project does not seem to be very active!)

Patch Uploaded: #17681

$
0
0

polipo has uploaded a patch.

Description:
This add two method for draw Polyline in antialias mode.

Viewing all 360 articles
Browse latest View live


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