bitmapimage

Loading image from cache using BitmapFactory.decodeStream() in Android

安稳与你 提交于 2019-12-31 04:39:09
问题 UPDATES : Even if i don't retrieve images from cache, i tried to retrieve via Drawable where i stored all the 18 images in the "drawable-mdpi" folder. Still, a blank screen was display. I was able to retrieved images from the server and save the image (.GIF) into the cache. However, when i need to load that image from cache, the image doesn't show up on screen. Here is the codes that does the work: File cacheDir = context.getCacheDir(); File cacheMap = new File(cacheDir, smallMapImageNames

Convert BitmapImage to byte[] array in Windows Phone 8.1 Runtime

天涯浪子 提交于 2019-12-31 02:53:14
问题 There are a few samples to do this but they are for Windows Phone 8.0 or 8.1 Silverlight. But how can you do this for Windows Phone 8.1 Runtime? 回答1: You cannot extract the pixels from a Windows.UI.Xaml.Media.Imaging.BitmapImage. The most general solution is to use a WriteableBitmap instead of a BitmapImage. These classes are both BitmapSources and can be used almost interchangeably. The WriteableBitmap provides access to its pixel data via its PixelBuffer property: byte[] pixelArray =

Creating 8bpp bitmap with GDI and saving it as a file

孤人 提交于 2019-12-30 11:28:27
问题 I have a perfectly working code that creates 32bpp bitmap and I need to change it so that 8bpp bitmap is created. Here's the piece of code that creates 32bpp bitmap, draws into it, then it creates a bitmap file and store it into the vector of bytes: // prepare bitmap: BYTE* bitmap_data = NULL; HDC hDC = GetDC(NULL); HDC memHDC = CreateCompatibleDC(hDC); BITMAPINFO bmi; memset(&bmi, 0, sizeof(BITMAPINFO)); bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biWidth = desiredWidth; /

How can I convert WriteableBitmap to BitmapImage?

。_饼干妹妹 提交于 2019-12-29 07:27:28
问题 BitmapImage bitmapImage = new BitmapImage(new Uri("arka_projects_as_logo.png", UriKind.Relative)); Image uiElement = new Image() { Source = bitmapImage }; ScaleTransform t = new ScaleTransform() { ScaleX = 0.2, ScaleY = 0.2 }; WriteableBitmap writeableBitmap = new WriteableBitmap(uiElement,t); I want to insert the result of this conversions (writeableBitmap) into System.Windows.Controls.Image. When I do this: Image arkaImage = new Image() { Source = writeableBitmap }; arkaImage isn't shown at

Proper way to dispose a BitmapSource

喜夏-厌秋 提交于 2019-12-29 01:35:10
问题 How are you supposed to dispose of a BitmapSource ? // this wont work because BitmapSource doesnt implement IDisposable using(BitmapSource bitmap = new BitmapImage(new Uri("myimage.png"))) { } 回答1: You do not have to Dispose() a BitmapSource. Unlike some other "image" classes in the Framework, it does not wrap any native resources. Just let it go out of scope, and the garbage collector will free its memory. 来源: https://stackoverflow.com/questions/1591996/proper-way-to-dispose-a-bitmapsource

Android handling out of memory exception on image processing

允我心安 提交于 2019-12-28 07:03:08
问题 This is the sequence part of this question: Combining 2 Images overlayed so the problem is: if the image size is too big - it'll got an exception (out of memory exception) what i want is, to handle even if the handset got the lower spec hardware, it doesn't go to that exception (but it'll take a longer time to process the image) is it possible to do that? the code snippet is like this: public static Bitmap overlay(Bitmap bmp1, Bitmap bmp2) { Bitmap bmOverlay = Bitmap.createBitmap(bmp1

Reloading an image in wpf

你。 提交于 2019-12-28 05:41:34
问题 I'm trying to reload an image (System.Windows.Controls.Image) I display in WPF. I set the source like this: ScreenAtco01Image.Source = new BitmapImage(new Uri(@"Y:/screenshots/naratco08-0-0-screenshot.png", UriKind.RelativeOrAbsolute)); I made a button, which should force a reload of this image (it changes on disk every second). I have tried resetting the Source, but that doesn't do anything. However if I change the Source to a different image, this different image does get loaded. It seems

Creating WPF BitmapImage from MemoryStream png, gif

柔情痞子 提交于 2019-12-27 11:43:12
问题 I am having some trouble creating a BitmapImage from a MemoryStream from png and gif bytes obtained from a web request. The bytes seem to be downloaded fine and the BitmapImage object is created without issue however the image is not actually rendering on my UI. The problem only occurs when the downloaded image is of type png or gif (works fine for jpeg). Here is code that demonstrates the problem: var webResponse = webRequest.GetResponse(); var stream = webResponse.GetResponseStream(); if

Creating WPF BitmapImage from MemoryStream png, gif

﹥>﹥吖頭↗ 提交于 2019-12-27 11:43:10
问题 I am having some trouble creating a BitmapImage from a MemoryStream from png and gif bytes obtained from a web request. The bytes seem to be downloaded fine and the BitmapImage object is created without issue however the image is not actually rendering on my UI. The problem only occurs when the downloaded image is of type png or gif (works fine for jpeg). Here is code that demonstrates the problem: var webResponse = webRequest.GetResponse(); var stream = webResponse.GetResponseStream(); if

Load large bitmap from url and resize it

我只是一个虾纸丫 提交于 2019-12-25 04:16:31
问题 I want load huge image from url and show on my device. I read this post for doing this. In that example they use native drawable but I want get image from server. I am using this code private void getBitmap(ImageView imageView,final String url){ mBitmapOptions = new BitmapFactory.Options(); mBitmapOptions.inJustDecodeBounds = true; URL mUrl = null; InputStream is= null; try { mUrl = new URL(url); is = mUrl.openStream(); } catch (MalformedURLException e) { e.printStackTrace(); } catch