How to set a placeholder for a Image control (while it downloads)? - silverlight

I have an app that show a list of images. The image source is set to a http URL, and the images are downloaded and display automatically.
However, while the app is taking time to download, the image control shows nothing. The user experience is not good this way.
How may I display a loading placeholder image, or a loading gauge, for each of the image control?

While an image is loading, it is drawn transparently. You can use this to your advantage to display an element underneath the image while it is loading. For example, you could have a stock image that is bundled with your XAP that represents a default avatar for example. Or you could display a XAML loading animation. Then when the image is finished loading, it will obscure the element behind it.
Mick's suggestion is a good one if you need to minimize your visual tree and if your scenario allows for a code solution. This suggestion is not perfect but it does make it easier to deal with the case where your placeholder image is unscaled/centered but the loaded image is scaled/stretched.

You could set the image source to your placeholder then when ImageOpened fires, change it to the remote url and let that run it's course.

In addition to the 2 other suggestions (from Josh & Mick) you could display a placeholder in the xaml and then, in code, download the actual desired image in the background using HttpWebRequest. Then when the image has fully downloaded save it to isolated storage and then update the source to the displayed image.
Yes this is more complex than the other solutions but would simplify the visual tree and avoid a blank image being displayed while the image is downloaded.
It would also give you offline caching of images too.

Interesting how many options there are for tackling this problem.
You might also like to consider Ben Gracewood's image caching implementation or what appears to be a development on that idea in his blog comments.
One-time Cached Images in Windows Phone 7 « Ben.geek.nz
Peter Nowaks Mobile Blog - “Intelligent” Image Caching for WP 7
Some background on the discussion leading up to this here if it's of interest.
Image control cache duration?

Related

How to reduce the jar size of a codename one app to stay under 50meg

My app is too large for the 50 meg limit so I am looking at some ways to significantly reduce the file size.
If I discard a dpi what happens when it runs on that dpi? I have some HUGE backgrounds making my app very bloated, I was wondering if I can remove them all but say the HD one and it would scale or would it be simply empty? Or would I need to change the background image scaling to make it do this?
Also CN1 seems to use png, can I use jpg for selected items to save space? Backgrounds that are 2.3 meg pngs could be 35k jpgs.. Even if I wrote a script that jpeged them after I press save in the gui designer, this could work I assume?
Any any further final tips for reducing the size of cn1 apps?
A 50mb app is not only big, but prone to be slow on devices (performance wise).
To reduce your App size tremendously, do the following:
All my answers are based on old GUI Builder
For background image, use a single image (not multi-image) and style the form UIID to use the image and type IMAGE_TO_FILL.
Avoid using png image whenever possible, CN1 supports jpg perfectly.
Don't use images for basic icons, use fonticon. Thousand of icons could be made 100kb and of high quality svg image that doesn't pixelate. I will explain at the end of this list how to create your custom fonticons.
Avoid using 9-piece border image where it's not really needed, try to use solid background color if it won't ruin your design.
Delete unused images, they also take a lot of space. On your GUI Builder.
Re-use UIIDs, instead of creating multiple similar UIIDs.
Migrate your GUI Builder forms to code, I posted a sample form Class to answer another question here and also talk about similar thing here.
Delete UIIDs you're not using and in most cases, copy and paste UUID of unselected style to selected, instead of creating similar.
Be Careful with this. Keep your GUI Builder open, make sure Xml team mode is checked under File, save the GUI Builder after deleting Unused Images, without closing the GUI Builder, go to your project folder -> res -> delete theme.xml and the theme folder inside res folder (The name might be different if you've renamed your theme.res file). Now go back to your app and save again. A fresh copy of your res files would be saved in the same folder.
Minimise the amount of background images you use, Modern good looking apps are simple plain background apps. E.g, Facebook, Twitter, Uber, AirBnB, BBC News App and many others. Unless your app is actually a game or necessarily require rich images that have to be static.
Watch this video about performance tuning, It's a bit old but still contains useful information
If your app is bigger than 20 mb on iOS and 5mb on android, you should be worried about it's performance.
Creating fonticons:
Go to fontello.com and check the icons present, if there are icons you need that are not there...
Go to flaticon.com and search for it there, download it as svg and drag'n'drop the svg on fontello webpage. If the icon doesn't look as expected...
Go back to flaticon.com and download the image as black 512px png image and go to online-convert.com, convert the png to Monochrome svg file, this helps you to create a compound image that works well with fontello.
download the fonticon as zip on fontello and follow Shai's chat app example to use it. the zip contains demo html file to preview your icons and also a config.json that can be drag'n'drop on fontello.com to continue where you stopped.

What's the Facebook/AirBnb app design effect called?

I want to read about that effect you see on pages like Facebook or Airbnb when you open the page and the browser shows you the low fidelity design of page while the actual data loads - so you'll see grey box instead in the place where pictures of the users will be, grey rectangles instead of the text content etc. I've been searching for hours but cannot find anything useful, anyone knows the name of this UX practice?
I believe this is referred to as loading dummy content. There wasn't much info when I searched for it, but I do know that the basic principle is first load a gray background for images and dummy block font then wait for your content to render.

Icons in WPF when to use image and when to use Xaml?

I am Working on a WPF based project where the design team have created the design in blend with some images like Edit, delete, checkbox etc. where i am prefring to use xaml insteed of images
Although i am sure that if the images are prety complex they should be used as images. but the simple im icon images can be used as xaml path designs. So i am looking for the recomandations. When to use Images in WPF design and When to use xaml for design.
If your application is going to be used in different screen resolutions then using Vector Graphics is recommended as they will scale nicely and all your images will look sharp regardless of the resolution of the screen. (There is a downside as well because your application needs to do the extra rendering of the xaml images to display them)
If you are using the images just to display the toolbar images (which are pretty much small and fixed size then you can get away by using png files as they will take less resources and easy to manage)

WPF Crop and resize an image without losing original image

I am trying to create a WPF control which crops and re-sizes an image via adorners without losing the original image ie once cropped it should be possible to get back the original by reversing the steps and the cropped image should also be resizeable.
Can't seem to come up with a viable solution.
Any bright ideas? Just need a general approach.
Check if this helps
http://www.codeproject.com/KB/WPF/CropAdorner.aspx
http://drwpf.com/blog/2007/09/08/image-manipulation-using-wpf-imaging-classes/
http://blogs.msdn.com/b/delay/archive/2007/11/11/bigger-isn-t-always-better-how-to-resize-images-without-reloading-them-with-wpf.aspx
check out
Interactive WPF image cropper control
you can download the source. should thank teamdistinction.

Image processing in Silverlight 2

Is it possible to do image processing in silverlight 2.0?
What I want to do is take an image, crop it, and then send the new cropped image up to the server. I know I can fake it by clipping the image, but that only effects the rendering of the image. I want to create a new image.
After further research I have answered my own question. Answer: No. Since all apis would be in System.Windows.Media.Imaging and that namespace does not have the appropriate classes in Silverlight
I'm going to use fjcore. http://code.google.com/p/fjcore/
Thanks Jonas
Well, you can actually do local image processing in Silverlight 2... But there are no built in classes to help you. But you can load any image into a byte array, and start manipulating it, or implement your own image encoder.
Joe Stegman got lots of great information about "editable images" in Silverlight over at http://blogs.msdn.com/jstegman/. He does things like applying filters to images, generating mandlebrots and more.
This blog discuss a JPEG Silverilght Encoder (FJCore) you can use to resize and recompress photos client size: http://fluxcapacity.net/2008/07/14/fjcore-to-the-rescue/
Another tool is "Fluxify" which lets you resize and upload photos using Silverilght 2. Can be found over at http://fluxtools.net/
So yes, client side image processing can definetly be done in Silverilght 2. Happy hacking!
I know this doesn't directly answer your question, but what if you do all of the clipping on the client side to crop the image, then send the server the original image and the coordinates for clipping. Then on the server side, which will probably more suited for image manipulation like this (e.g. PHP it's very easy) you'll do the actual cropping of the image and storing the cropped version.
There is first-class support for bitmap surfaces in Silverlight 3: http://blogs.msdn.com/kaevans/archive/2009/03/20/some-silverlight-3-goodness-using-writeablebitmap.aspx

Resources