c# - Is there a way to keep a png/jpg image from being converted to a bitmap image -


I am creating a C # / WPF / Windows 8 App Store app and I try to load some PNG / JPG Images to display to see them are all highly high resolution, but the size of the file is usually only around 200k or the problem is that when I get them a bitmap image class (which can only be found one ), The total used to be used Memory increases to 100 S mega. What I can tell, it takes png / jpb and converts it to a bitmap image, which extends memory usage to a large extent.

Am I missing something?

My code is down, so far I have not found any way around it, though it seems that there should be a simple solution. Private async Task Test Function (IRD ONLY LIST & lt; StorageFile & gt; Files) {var images = new ObservableCollection & lt; Image & gt; (); ImagePanel.ItemsSource = coverImages; Foreign files (files) {var bitmap = new bitmap image (); Var item = await file.OpenAsync (FileAccessMode.Read); Bitmap.SetSource (item); Var image = new image (); Image.Source = bitmap; Image. Heights = 200; Images.Add (image); }}

If the image on disk is in compressed format (and most of the image file format Type compression), the in-memory footprint will be larger.

If the image is 100x100 pixels in size and uses 8bits for color depth, the raw data of that image is 100x100 = 10,000 bytes and this is the data that is sung on the screen.

If you are looking for a way to reduce memory usage in your WPF application, then you can choose some options.

  1. Do not cache images in memory or Bitmap option options such as: to load images using bitmap.CacheOption = bitmapCacheOption.None Choose the best time for this This will fill the required image from the disk, if the image is only 200k, the display drop should not be too bad, but it will not be as fast as caching

  2. Ensure that you need as much as possible to present images If you are displaying an image on 200x200 and the image is 1024x768, you can set the decode pixelweb , for the size you define Bitmap will create its actual size eg: bitmap.DecodePixelWidth = 200

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -