View Issue Details

IDProjectCategoryView StatusLast Update
0001497NoesisGUIC# SDKpublic2019-06-20 11:32
ReporterVince_1990 Assigned Tosfernandez  
PrioritynormalSeverityfeature 
Status resolvedResolutionno change required 
Product Version2.2.3 
Summary0001497: BitmapImage from stream/byte[]
Description

I have a database with images (Couchbase if it matters).
wich stores images in memory and i can get them with a stream or byte[].
In the current situation i have to write them to disk and then load them up through an Uri, wich is cumbersome.

It would there fore be awsome if we could just pass a stream/byte[] and get the ImageSource in return.

OR an tutorial on how to use Bitmapsource.Create

PlatformWindows

Activities

sfernandez

sfernandez

2019-06-19 17:41

manager   ~0005746

You should be able to use BitmapSource.Create just fine passing the byte array:

byte[] pixels = memoryStream.ToArray();
BitmapSource bmp = BitmapSource.Create(pixelWidth, pixelHeight, 96.0, 96.0, pixels, pixelWidth * 3, BitmapSource.Format.RGB8);

Are you getting any error with this approach?

Vince_1990

Vince_1990

2019-06-19 19:32

reporter   ~0005747

Last edited: 2019-06-20 10:22

Tried it but doesn't work.

I don't know the pixels width.Height so i used:

Bitmap b = new Bitmap(File.ContentStream);
ImageSource Is = BitmapSource.Create(b.Width, b.Height, b.HorizontalResolution, b.VerticalResolution, File.Content,b.Width 3, BitmapSource.Format.RGB8);
80 80 96 96 byte[2162] 80
3
Source:
http://i64.tinypic.com/14in0np.png

Result:
http://i68.tinypic.com/24nis5v.png

The file is an .jpg file.
When i write it to disk and hit properties is lists with an Bitdepth of 24

jsantos

jsantos

2019-06-20 10:53

manager   ~0005750

I am not sure this is the best approach. If you already have the images in a database I think the best way is installing a TextureProvider that will allow you to return a Stream for each requested URI.

Vince_1990

Vince_1990

2019-06-20 11:07

reporter   ~0005751

I Already use a custom texture provider for loading images from filesystem, wich indeed needs an uri and spills out an stream.
But problem is i cannot acces the files in the database by Uri.
When i open the database, the images are loaded into the ram, and in the c# object i can only get a stream or a byte[].

sfernandez

sfernandez

2019-06-20 11:32

manager   ~0005752

I think this is not a bug and it is better to discuss it in the forums, because it can help others in the same situation, could you please create a post there?

Issue History

Date Modified Username Field Change
2019-06-19 17:12 Vince_1990 New Issue
2019-06-19 17:12 Vince_1990 Tag Attached: C#
2019-06-19 17:31 Vince_1990 Summary Load BitmapImage from stream => BitmapImage from stream/byte[]
2019-06-19 17:41 sfernandez Assigned To => sfernandez
2019-06-19 17:41 sfernandez Status new => feedback
2019-06-19 17:41 sfernandez Note Added: 0005746
2019-06-19 19:32 Vince_1990 Note Added: 0005747
2019-06-19 19:32 Vince_1990 Status feedback => assigned
2019-06-19 19:33 Vince_1990 Note Edited: 0005747
2019-06-19 19:34 Vince_1990 Note Edited: 0005747
2019-06-19 19:43 Vince_1990 Note Edited: 0005747
2019-06-19 20:17 Vince_1990 Note Edited: 0005747
2019-06-19 20:40 Vince_1990 Note Edited: 0005747
2019-06-20 10:21 Vince_1990 Note Edited: 0005747
2019-06-20 10:22 Vince_1990 Note Edited: 0005747
2019-06-20 10:53 jsantos Note Added: 0005750
2019-06-20 10:53 jsantos Status assigned => feedback
2019-06-20 11:07 Vince_1990 Note Added: 0005751
2019-06-20 11:07 Vince_1990 Status feedback => assigned
2019-06-20 11:32 sfernandez Status assigned => resolved
2019-06-20 11:32 sfernandez Resolution open => no change required
2019-06-20 11:32 sfernandez Note Added: 0005752