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

New Post: issues using blit for simple 'color me' (coloring picture) app: inkmanager's size limited to strokes


New Post: issues using blit for simple 'color me' (coloring picture) app: inkmanager's size limited to strokes

$
0
0
I previously have had a look at the thread, however I still cannot figure out how to get it to work properly. A bit more explaining would be helpful.. should I indeed focus on doing something with the rectangles?

Created Issue: Reading a Bitmap from a Stream not respecting EXIF flag [19582]

$
0
0
In the FromStream method of WriteableBitmapConvertExtensions the BitmapDecoder is using ExifOrientationMode.RespectExifOrientation but the new WriteableBitmap is created with the original PixelWidth and PixelHeight. This leads to weird image effects when reading photos from an iOS or Android device.

Fix
Change:
bmp = new WriteableBitmap((int)decoder.PixelWidth, (int)decoder.PixelHeight);

to:
bmp = new WriteableBitmap((int)decoder.OrientedPixelWidth, (int)decoder.OrientedPixelHeight);

cheers
Perry

Source code checked in, #99832

$
0
0
* Uses OrientedPixelWidth *Height for WinRT FromStream now to respect Exif data fixes #19582

Edited Issue: Reading a Bitmap from a Stream not respecting EXIF flag [19582]

$
0
0
In the FromStream method of WriteableBitmapConvertExtensions the BitmapDecoder is using ExifOrientationMode.RespectExifOrientation but the new WriteableBitmap is created with the original PixelWidth and PixelHeight. This leads to weird image effects when reading photos from an iOS or Android device.

Fix
Change:
bmp = new WriteableBitmap((int)decoder.PixelWidth, (int)decoder.PixelHeight);

to:
bmp = new WriteableBitmap((int)decoder.OrientedPixelWidth, (int)decoder.OrientedPixelHeight);

cheers
Perry
Comments: ** Comment from web user: teichgraf **

Fixed in revision 99832

New Post: Pixelate an image

$
0
0
Have you tried resizing it to a smaller size (4x smaller for example if you want 4 times bigger pixels) and then resizing it back to original?

New Post: GetPixel throws an AccessViolationException

$
0
0
Hi, I am quite new to WriteableBitmapEx. I tried to load a png file in a WinRT Project by using a WriteableBitmap object and WriteableBitmapEx included via nuget.
The Image is http://commons.wikimedia.org/wiki/File:Plan.cathedrale.Amiens.png

My code is
        async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            WriteableBitmap image = new WriteableBitmap(100, 100);

            StorageFile file = await Package.Current.InstalledLocation.GetFileAsync("Assets\\Plan_cathedrale_Amiens.png");

            IRandomAccessStreamWithContentType randomAccessStream = await file.OpenReadAsync();
            image.SetSource(randomAccessStream);
            this.Transform(image);
        }
        private void Transform(WriteableBitmap source)
        {
            Color bottomleft = source.GetPixel(5, 5);
        }
The line Color bottomleft = source.GetPixel(5, 5); is the one goind bad and throwing an AccessViolationException.

I would very much appreciate any help.

Best Regards,
Andreas

New Post: GetPixel throws an AccessViolationException

$
0
0
It's simply not loaded at the time you want to access the pixels. Just check the PixelWidth and Height properties.
You should use the WBX methods to load your stuff:
Uri imageUri = new Uri(BaseUri, "///Assets/Plan_cathedrale_Amiens.png");
image = await BitmapFactory.New(1, 1).FromContent(imageUri);
  • Rene

New Post: Gradient Brush?

$
0
0
Is there any possiblity to use Brushes like Gradientbrush,...?
If not what could I use to get better performance than DrawingVisual but still the possibility to draw with brushes.

New Post: issues using blit for simple 'color me' (coloring picture) app: inkmanager's size limited to strokes

$
0
0
My current code is this:
//Image background
            var backgroundBmp = await BitmapFactory.New(1, 1).FromContent(new Uri(BackgroundImage));
            //Image foreground
            WriteableBitmap foregroundBmp;
            using (InMemoryRandomAccessStream a = new InMemoryRandomAccessStream())
            {
                await _inkManager.SaveAsync(a);
                a.Seek(0);
                foregroundBmp = await new WriteableBitmap(1, 1).FromStream(a,BitmapPixelFormat.Bgra8);
            }
            // Combined
            backgroundBmp.Blit(new Rect(0, 0, foregroundBmp.PixelWidth,foregroundBmp.PixelHeight), foregroundBmp, new Rect(0, 0,backgroundBmp.PixelWidth,backgroundBmp.PixelHeight), WriteableBitmapExtensions.BlendMode.Alpha);

            // Save
            FileSave = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(TempFileNameForDrawing, CreationCollisionOption.ReplaceExisting);
            Guid encoderId = Windows.Graphics.Imaging.BitmapEncoder.PngEncoderId;
            await WinRTXamlToolkit.Imaging.WriteableBitmapSaveExtensions.SaveToFile(backgroundBmp, FileSave, encoderId);
In the backgroundBmp.Blit line I use the rectangle from the foregroundBmp and the backgroundBmp. They are however different in size, which you would expect since the inkManager on which the foregroundBmp is based only returns the actual strokes and the rectangle bounding those. How would I go about getting the inkmanager to return the full canvas?

New Post: Is it possible to add text to writeablebitmap in metro style app

$
0
0
Hi
I just want to add text to the writeablebitmap and save to .png files,
So I referenced the below discussion thread
Is it possible to add text to bitmap?
public static void DrawText(this WriteableBitmap wBmp,Point at, string text,double fontSize,Color textColor)
    {        
        TextBlock lbl = new TextBlock();
        lbl.Text = text;
        lbl.FontSize = fontSize;
        lbl.Foreground = new SolidColorBrush(textColor);
        WriteableBitmap tBmp = new WriteableBitmap(lbl, null);
        wBmp.Blit(at, tBmp, new Rect(0, 0, tBmp.PixelWidth, tBmp.PixelHeight), Colors.White, System.Windows.Media.Imaging.WriteableBitmapExtensions.BlendMode.Alpha);
    }
But this way seems like can't be used in metro style app ....

New Post: Is it possible to add text to writeablebitmap in metro style app

$
0
0
Indeed, WinRT does not allow rendering of the Visual Tree. :( But that might change in the next version. In the meantime you can use blitting with bitmap fonts.

New Post: Simple image blitting/compositing with a background image and a foreground image.

$
0
0
Hi Guys,

I am trying to add source image to destination image using blit function.

I used above code but it is not working for me.

Can any one help me please.

Here is my code..


Dim objRoomItem As SurveyDataSource.RoomItem = DirectCast(itemListView.SelectedValue, SurveyDataSource.RoomItem)
        Dim strImageData As String = GetByteArray(objInkManager)
        'cvink.Children.Clear()


        Dim background = BitmapFactory.[New](imgItem.ActualWidth, imgItem.ActualHeight).FromByteArray(Convert.FromBase64String(objRoomItem.ImageFile))

        Dim forground As WriteableBitmap = BitmapFactory.[New](objInkManager.BoundingRect.Width, objInkManager.BoundingRect.Height).FromByteArray(Convert.FromBase64String(strImageData))

        forground.Blit(New Rect(0, 0, background.PixelWidth, background.PixelHeight), background, New Rect(0, 0, background.PixelWidth, background.PixelHeight), WriteableBitmapExtensions.BlendMode.Alpha)

        'background.Blit(New Rect(0, 0, background.PixelWidth, background.PixelHeight), forground, New Rect(0, 0, forground.PixelWidth, forground.PixelHeight), WriteableBitmapExtensions.BlendMode.Alpha)
        'background.Clear(Windows.UI.Colors.White)

        Dim tempData As Byte()
        ReDim tempData(forground.PixelBuffer.Length)

        tempData = background.PixelBuffer.ToArray()

        strImageData = Convert.ToBase64String(tempData)

New Post: Bliting two WriteableBitmap with WriteableBitmapEx

$
0
0
I tried to blit two writeablebitmap. However, the debugger prompted a error message stating the followings:
The input WriteableBitmap needs to have the Pbgra32 pixel format. Use the BitmapFactory.ConvertToPbgra32Format method to automatically convert any input BitmapSource ?to the right format accepted by this class.
Here is my code.
Rect cRect =new (320,240);
WriteableBitmap _bitmap = new WriteableBitmap(320, 240, 96, 96, PixelFormats.Bgr32, null);
_bitmap.WritePixels(new Int32Rect(0, 0, 320, 240), _image, 320*240, 0);    //_image is a image stream                  
_bitmap.Blit(cRect, _imageFrame, cRect); //_imageFrame is another writeablebitmap

New Post: Bliting two WriteableBitmap with WriteableBitmapEx

$
0
0
What the error message says.
  • Rene

New Post: Bliting two WriteableBitmap with WriteableBitmapEx

$
0
0
Thank you Rene.

One more question.
Now I understand the problem. However, if I want to the output writeablebitmap as a Bgr32 one. Is there any way to convert _imageFrame to blit?
Adam

New Post: Bliting two WriteableBitmap with WriteableBitmapEx

$
0
0
All WriteableBitmapEx algorithms rely on the Pbgra32 format, so all your bitmaps have to use that format.

New Post: AccessViolationException when accessing pixel color (GetPixel())

$
0
0
Hi,

I'm using WriteableBitmapEx to edit an image taken with tablet's cam with Windows 8 Pro but I got an AccessViolationException every time I try to get a pixel color value, here's the code:
Windows.Media.Capture.MediaCapture captureMgr = new MediaCapture();
await captureMgr.InitializeAsync();

IRandomAccessStream memoryStream = new InMemoryRandomAccessStream();
await captureMgr.CapturePhotoToStreamAsync(imageProperties, memoryStream);
await memoryStream.FlushAsync();
memoryStream.Seek(0);

WriteableBitmap tmpImage = new WriteableBitmap(1, 1); 
tmpImage.SetSource(memoryStream);
tmpImage.GetPixel(1, 1); // An AccessViolationException occurs.
What I'm doing wrong? Or maybe a library bug?

New Post: AccessViolationException when accessing pixel color (GetPixel())

$
0
0
You are using it wrong. The WinRT's SetSource will not load it right away, so when you access a pixel the buffer is not filled. Just check PixelWidth and PixelHeight

That's why WBX has the FromStrean extension method:
var tmpImage = await BitmapFactory.New(1, 1).FromStream(memoryStream);
  • Rene

New Post: Simple image blitting/compositing with a background image and a foreground image.

$
0
0
Hey guys,

I am waiting for your reply.

Please its urgent.!!!!:(
Viewing all 360 articles
Browse latest View live


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