Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8703693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:55:29+00:00 2026-06-13T02:55:29+00:00

I try to write function that will be resize images. I use WriteableBitmapEx for

  • 0

I try to write function that will be resize images. I use WriteableBitmapEx for WinRT/Win8 function Resize();

public class PictureExtension 
{
    private MemoryRandomAccessStream _memoryRandomAccessStream;
    private readonly Stream _dataStream;
    private readonly double _height;
    private readonly double _width;

    public PictureExtension(Stream dataStream, double height, double width)
    {
        _dataStream = dataStream;
        _memoryRandomAccessStream = (_dataStream.ToRandomAccessStream());
        _height = height;
        _width = width;
    }

    public byte[] ToArray(double maxSide)
    {
        if (_height <= maxSide && _width <= maxSide)
        {
            return _dataStream.ToArray();
        }
        else
        {
            var target = new WriteableBitmap((int) _width, (int) _height);

            var aspectRatio = (double)_width / _height;
            double newHeight;
            double newWidth;
            if (_width > _height)
            {
                newWidth = maxSide;
                newHeight = newWidth / aspectRatio;
            }
            else
            {
                newHeight = maxSide;
                newWidth = maxSide * aspectRatio;
            }

            int count = (int)_dataStream.Length;

            using (var bmpStream = target.PixelBuffer.AsStream())
            {
                bmpStream.Seek(0, SeekOrigin.Begin);
                bmpStream.Write(_dataStream.ToArray(), 0, _dataStream.ToArray().Length);
            }


            var resized = target.Resize((int)newWidth, (int)newHeight, WriteableBitmapExtensions.Interpolation.Bilinear);

            return resized.ToByteArray();

        }

    }
}

}

This function return array of byte but it is not image any more.. I tested with PNG and JPG formats.. What’s wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:55:30+00:00Added an answer on June 13, 2026 at 2:55 am

    I’ve been examining this problem before, try the code in this thread:
    How to resize Image in C# WinRT/winmd?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write a delegate function that can 'wrap' some while/try/catch code around
(Important: See update below.) I'm trying to write a function, import_something , that will
I am trying to write a simple function that will get me a number
I have a class that holds an "error" function that will format some text.
I'm trying to write a function that will take the email of the user
i'm need to write a function that will flip all the characters of a
Is there a convenient way to write a regex that will try to match
I'm trying to write a class that when asked on, will call on a
I'm trying to write a replacewith function in jQuery that will replace specific words
I need to write a function that will concatenate a list into a string.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.