Setting BackBackgroundImage with local file for live tile WP7 - windows-phone-7

this might be really simple and I've tried searching but I haven't been able to find a solution.
My problem is quite basic. I am having trouble setting the BackBackgroundImage uri path to a local static png that I've made.
Here is the code I am using to generate the tile:
ShellTile testtile = ShellTile.ActiveTiles.First();
if (testtile != null)
{
StandardTileData newtiledata = new StandardTileData
{
Title = "Test Title",
Count = 0,
BackContent = "Test Content",
BackBackgroundImage = new Uri("Content/BackTileIcon.png", UriKind.Relative)
};
testtile.Update(newtiledata);
}
The problem is that I can't get BackTileIcon.png to display. I get the "Test Content" displaying fine and the tile flips back to the front image OK, it's just the back image that I can't display.
If I open the XAP after building I can see that there is a Content folder and inside the content folder is the BackTileIcon.png file.
I can't work out the format I need for the Uri for a local image in a subfolder. I changed the Uri to point to my games large icon which is included in the root folder (so the Uri path is just "LargeAppIcon.png") and that works so I know the code updates the back image OK with a correct path.
Am I just doing something stupidly wrong here?
Thanks for any help :)

In order to use a local image in your live tile, the image has to be in the IsolatedStorage under the folder /Shared/ShellContentand and not in your project.
You either have to generate the image in the application and save it directly in the isolatedStorage, or copy your content image in there at runtime.

Related

Xamarin - how to reset image cache for a specific image

In my Xamarin app I upload a new "user profile" image on the server, then I try to update the image with the new version of the image (Noticed that the image uri is the still the same).
There is an image cache provided by Xamarin, I need to invalidate it to force the image to reload from the server. But it seems that the Image cache cannot be invalidated ! I find no solution !
I have try several solutions, but find no way ! Even when I restart the application I get the old version of the image.
I have try some stuffs like this :
(MediaImageSource as UriImageSource).CacheValidity = new TimeSpan(-1);
FFImageLoading.Forms.CachedImage.InvalidateCache(MediaImageSource, FFImageLoading.Cache.CacheType.All, true);
FFImageLoading.ImageService.Instance.InvalidateCacheAsync(FFImageLoading.Cache.CacheType.All);
But nothing work, any idea is welcome ? Thx
I do the following:
// this.Img is the FFImageLoading.CachedImage in my view
var source = this.Img.Source as FileImageSource;
// Reset cache using the global instance (the key is the file name, I assume it is the uri for UriImageSource)
await ImageService.Instance.InvalidateCacheEntryAsync( source.File, CacheType.All, true );
// Reassign the image source (since the binding has not changed per se, the UI may miss the change otherwise)
this.Img.Source = new FileImageSource(...);
This reloads the image and FFImageLoading even does a nice fade animation when it changes.
There is actually a static method in CachedImage that accepts any kid of ImageSource, so there is no need to guess the key:
FFImageLoading.Forms.CachedImage.InvalidateCache(myImageSource, CacheType.All, true);

Unity 3D: Loading an image from device memory shows an image with Question mark

Am taking a snap and setting that image as background to other scene,but finally that background is showing a question marked image..
FYI the image already exists, i have checked that with File.exists(). and here is the code snippet i have used.
IEnumerator DisplayTexture() {
WWW www = new WWW(SelfiateUtils.SnapImagePath);
yield return www;
BGTexture.mainTexture = www.texture;
//Trace.text="Assaigned successfully";
if (www.error == null) {
}
}
SelfiateUtils.snapImage is the string url where i have saves the file.
can any one help me to fix this.
thanks.. :)
Just to complement the answer in the comments and give it more visibility, as stated by Sharath, one must add "file://" as as prefix to load image files (jpg, jpg) in iOS.
This particularly important to remember when loading streaming assets. This prefix must be added before Application.streamingAssetsPath in iOS and also when running the app in the Unity Editor (Win and MacOS). In Android this prefix should be omitted.

AS3: How do I definitively smooth a bitmap image loaded from an outside server

This issue has been following me around for almost a year now, and I want to kill it, for my sake and for the sake of all.
I'm working on some banner ads that need to load in images from a client's site for display. When I tried to do this using AS2, I found out that AS2 doesn't let you do that. It's a bug in the language. There are workarounds for images on the local server, but images loaded from are not allowed to share their BitmapData, so those workarounds don't work. I ended up capitulating after about two months of banging my head against the desk and cursing Macromedia.
Now we are talking about moving to AS3 (finally) and I'm really excited. Or, I was really excited until I started doing some tests for image quality and found that there is very little change in image quality happening here. It's a repeat of my trials with AS2: everything loads perfectly in the IDE, I get all excited, I move the swfs over to the test server to run them online, and POOF - jaggies. Jaggies everywhere.
I've read a number of solutions online, none of which work. They include:
Setting target.content.smoothing to "true". Works great in the IDE. All improvements disappear in the browser.
Setting target.scaleX = target.scaleY to 1.01. It just breaks the swf.
Adding "new LoaderContext(true)" to my parameters for the load command. Does nothing.
Setting target.content.pixelSnapping to "always". Looks perfect in the IDE, not in the browser.
Setting a crossdomain.xml file. The images are showing up - they're being loaded, even if jaggedly, so there must be a functioning crossdomain file on the client's server, right?
So now I'm just stuck, and brokenhearted. Could anyone offer insight on my code, and why it might not be rendering as beautifully as it should be? Here is the client-safe version of the quick demo I am making (only the image URL has been deleted, everything else is as it is now):
import flash.events.Event;
function completeHandler(e:Event) {
e.target.content.pixelSnapping = "always";
e.target.content.smoothing = true;
}
var imgurl:String = "CLIENT'S IMAGE URL HERE";
var imageLoader01:Loader = new Loader();
var image01:URLRequest = new URLRequest(imgurl);
imageLoader01.load(image01);
imageLoader01.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
addChild(imageLoader01);
imageLoader01.x = 2;
imageLoader01.y = 0;
imageLoader01.scaleX = imageLoader01.scaleY = .6;
var imageLoader02:Loader = new Loader();
var image02:URLRequest = new URLRequest(imgurl);
imageLoader02.load(image02);
imageLoader02.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
addChild(imageLoader02);
imageLoader02.x = 100;
imageLoader02.y = 80;
imageLoader02.scaleX = imageLoader02.scaleY = .308;
var imageLoader03:Loader = new Loader();
var image03:URLRequest = new URLRequest(imgurl);
imageLoader03.load(image03);
imageLoader03.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
addChild(imageLoader03);
imageLoader03.x = 200;
imageLoader03.y = 180;
imageLoader03.scaleX = imageLoader03.scaleY = .152;
var bannerLegend:legend = new legend();
addChild(bannerLegend);
Thank you very much in advance. Any help will be sorely appreciated.
Update: Here is the HTML embed code:
<div id="swf_mr_sc_wt_si"></div>
<script type="text/javascript">
<!--
var swfurl = "http://DOMAIN_WITHELD_SORRY/static/AS3.swf?m=DEFAULT&t=" + (new Date().getTime());
swfobject.embedSWF(swfurl, "swf_mr_sc_wt_si", 300, 250, "8.0.0", "");
// -->
</script>
<p>
Hope this helps.
Further Update: We are not listed in the crossdomain.xml file. But we can still load the jagged images. And those images, when loaded into the same swf run in the IDE, are smooth. I think I'm missing understanding of some kind of apocryphal knowledge here, because everything I read points to me being able to do this. This is VERY confusing.
It's because the image you're loading is located on another domain, and that domain's crossdomain.xml does not contain the domain the .swf is residing on, basically giving the .swf "permission" to access the image's pixel data (Yes, just enabling smoothing on an image loaded from another domain requires the same security as when reading the pixel data using BitmapData.draw(), which is a bit curious). When running in local security sandbox the restrictions are more lax, that's why it works running from the IDE.
Even if your domain were among the approved domains in the crossdomain.xml you might need to tell the Flash Player to check the policy file by sending in new LoaderContext(true) as a second argument to Loader.load() when loading the image.
Edit: I originally thought using loadBytes() would be a workaround, but it turns out it's not. I have removed that example code

Is there a size restraint for background image for standard tile data?

I'm trying to create a secondary tile with StandardTileData:
StandardTileData tileData = new StandardTileData()
{
Title = "",
BackgroundImage = new Uri("/wifi.png", UriKind.Relative)
};
But the BackgroundImage is not set, are there some size restrictions? Do the image have to have a certain property set?
Image size is not the problem here, it's the file location.
Your BackgrounImage image has to be saved into shared folder:
If the URI references an image that was stored in isolated storage,
then the image must be in the Shared\ShellContent folder. For more
information, see Data for Windows Phone.

Titanium mobile Get saved image path

i have been using this code to store an image from imageviewer to device memory.
blobObj = imageView.toImage();
var f = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,'img.png');
f.write(blobObj);
Titanium.Media.saveToPhotoGallery(f,{
success: function(e) {
Titanium.UI.createAlertDialog({
title:'Photo Gallery',
message:'Check your photo gallery for image '
}).show();
},
error: function(e) {
Titanium.UI.createAlertDialog({
title:'Error saving',
message:e.error
}).show();
}
});
What i want is to get the native path of currently saved image from memory
Thankyou
Dear Please see the below example to get native path where the image is stored in titanium
file system
// Native path
var filename = "image.png";
// Create the file in the application directory
bgImage = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, filename);
// Write the image to the new file (image created from camera)
bgImage.write(image);
// bgImage.nativePath, it is alos native path, but you can get through below code.
nativePath = Titanium.Filesystem.applicationDataDirectory + Ti.Filesystem.separator + filename;
alert(nativePath);
Hopefully, it will for you. It is working on my side.
As this only works on iOS (see docs) i guess you are on iOS Platform.
If you create an image via blobObj = imageView.toImage(); you will receive a Titanium.Blob object. This object can be persisted somewhere in your app, it can also be temporarily available in memory.
If you store this image to the media gallery you won't get a file path to this image as this is not allowed by the iOS platform. So finally: What you want to do is not possible.
But: You can store the image yourself persistently within your app's data storage (using Ti.Filesystem).
To retrieve a file path for the temp object use f.nativePath or f.resolve().
Don't forget: You'll never get a path to the media gallery's photos. Even if you load an image from there you'll get a temporary path.

Resources