Load RAW image to Canvas in WPF (C#)

729 Views Asked by At

I'm trying to load .RAW image from file and display it into canvas background (in WPF). File only contains HEX data (without header, but resolution and color is known) - photo viewer cannot display it (because there is no info in header), however in IrfranView after resolution and color is specified, it can be displayed.

Sorry if any duplicates exist, I tried to find some solutions carefully but unfortunately I couldn't find any solution, that worked int WPF. Mostly they were designed for Forms app, not WPF.

To specify my question: How to load .raw data from file, convert it to bitmap and display it in canvas background? Width and height, color (32bit RGBA) are known and pixel HEX raw data are stored in .raw file.

1

There are 1 best solutions below

0
On

Welcome to SO.

Be aware that this question may get flagged for deletion because you haven't posted any code and you haven't asked a specific question. "Please write code for me" questions generally aren't well received in these parts, you might want to read up on the site rules.

To answer your question though, you don't load images onto a Canvas, you load them into an Image element (which can itself be placed inside a Canvas if you want). There are samples on the Microsoft site showing showing how to create one of these from a raw array of integers.