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);
Related
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.
Hello Friends I am New to WP7
i am working on small app now..
In that App i take one Pic from my camera and trying to save that in saved pictures with some name and i like to retrieve that Images and display again in my App Gallery screen
I am Using Pivot control for this app
in my first PivotItem Name is Gallery and second PivotItem name is Camera
Now i am working with camera fine
After taking my picture from camera i like to add some Note for that and save to my saved images and retrieving same image back and display in Gallery with Note wt i save
can any one say
how can i complete this App in good way
Code for save Images im using
mainpage.xaml.cs
private void saveimg_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
string fileName = myValue.ToShortDateString() + ".jpg";
var library = new MediaLibrary();
//library.SavePictureToCameraRoll(fileName, e.ChosenPhoto);
library.SavePicture(fileName, imageBits);
MessageBox.Show("Photo Saved to Picture Hub");
}
I need to Retrieve that that saved Image and display in my App when it loaded
If you need to access your image once it has been saved in the Media Library, you should also save it to the Isolated Storage.
Here is a tutorial that shows how to do that:
http://www.windowsphonegeek.com/tips/All-about-WP7-Isolated-Storage---Read-and-Save-Images
Save the image to Isolated Storage and Pictures Gallery. When wanting to see the image through the app, use image from Isolated Storage.
No need to use SQLite, use index numbers to save your image in Isolated storage, and also store comments with index numbers, that might ease you.
I'm trying to smooth an scaled image loaded from another website. The image is not animated.
It works well if I use a local image. but it seems not work with images loaded from remote server.
Here is the snippet:
...
//_loader.load(new URLRequest(http://img.example.com/remote.jpg));
_loader.load(new URLRequest("../assets/local.jpg"));
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
...
protected function completeHandler(event:Event):void
{
var image:Bitmap = Bitmap(event.target.content);
image.smoothing = true;
image.pixelSnapping = "never";
}
As tested, when I load local.jpg, it works perfect. But when I load remote.jpg from the server, the smoothing param didn't work.
Anyone knows why?
I searched everywhere, but no one has the same problem. I'm not using Flash Professional, it's a pure ActionScript Project built in Flash Builder. And the image is not animating. So wired...
Because you are pulling an image from a remote server you need to set a cross domain policy xml file on the web server where the image is held.
Without this you can't alter bitmaps at a sub pixel level.
Example of:
http://www.senocular.com/pub/adobe/crossdomain/policyfiles.html
More details
http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.edu.html
I searched day by day, and finally find the answer:
_loader.load( new URLRequest("http:…." , new LoaderContext(true));
The most important is the second param of load() method, it's a LoaderContext. Reference:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Loader.html#load()
Although I set the crossdomain file in the server, without the "new LoaderContext(true)", it won't read the crossdomain file. That's why it doesn't work at first.
If you have the same problem, hope it's helpful to you!
I'm trying to add and if needed by user, change the image from a widget in python.
I'm using Glade with gtk2+, python 2.7.3, and these is what I'm doing
image = gtk.Image()
image.set_from_file("MyImagePath.png")
image.show()
button = App.get_object('buttonExample')
button.add(image)
and this is what I get when try to change the image
GtkWarning: Attempting to add a widget with type GtkImage to a
GtkAspectFrame, but as a GtkBin subclass a GtkAspectFrame can only
contain one widget at a time; it already contains a widget of type
GtkImage
The image is loaded correctly as expected, but if I change the input path for image, I wish I could change the button image, but this is not what I'm getting.
I tried to use gtk.Image.clear(), but it says I cannot use it on a button (maybe im just messing things around)
Is there a good way to load and reload images to a button?
Thx
You either have to remove the old image from the button before adding a new one (the error message is pretty straightforward about this), or you could try changing the current image:
button.get_child().set_from_file("MyImagePath.png")
This was exactly what I needed. I used the clear in the image as you said and also cleaned the button image, as follows:
App.get_object('buttonExample').remove(image)
image.clear()
Thank you very much for you help!
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.