Xamarin iOS FFImageLoading load image from asset-library - ios

I can't load image from an ImageCached object on iOS.
I got an asset-library url from the ALAsset but when I create the ImageCached object it d'ont show the image, ending with error that file is not found.
I take the image url from (ALAsset)asset.AssetUrl.AbsoluteString
Here is the bit of code that init my CachedObject
CachedImage image = new CachedImage();
image.Source = url;
image.HeightRequest = heightRequest;
image.WidthRequest = widthRequest;
image.DownsampleWidth = downSample;
image.CacheDuration = TimeSpan.FromDays(30);
image.LoadingPlaceholder = "Images/loading_grey.png";
image.ErrorPlaceholder = "Images/placeholder.png";
image.Transformations = new System.Collections.Generic.List<ITransformation>() {
new CropTransformation(1, image.Width / 2 - heightRequest, image.Height / 2 - widthRequest)
};
image.CacheType = FFImageLoading.Cache.CacheType.Disk;
image.GestureRecognizers.Add(new TapGestureRecognizer
{
Command = new Command(() => {
Navigation.PushModalAsync(new ViewImagePage(url));
}),
NumberOfTapsRequired = 1
});
return image;
From an another posts i got a trail with this when i browse my image
ImagesNames.Add(asset.DefaultRepresentation.Url.AbsoluteString);
But image Path just link to asset.JPG that doesn't point to the file

Related

How to use -highlight-color in MagickImage?

SetLowlightColor does not work!
using (IMagickImage img1 = new MagickImage(Path.Combine(fullpath, IMAGE1)))
{
using (IMagickImage img2 = new MagickImage(Path.Combine(fullpath, IMAGE2)))
{
using (IMagickImage imgDiff = new MagickImage())
{
img1.ColorFuzz = new Percentage(fuzz);
imgDiff.SetLowlightColor(new MagickColor(Color.Blue));
double diff = img1.Compare(img2, ErrorMetric.Absolute, imgDiff);
imgDiff.Write(result);
}
}
}
https://www.imagemagick.org/Usage/compare/
It appears that you have discovered a bug in the Magick.NET library. I just published version 7.1.0.0 of the library to resolve your issue. But I have also decided to move the SetLowlightColor from the MagickImage class and introduce a new class called CompareSettings where you can set the Lowlightcolor. This property is moved because it is only used by the compare method. Your code should be changed to this:
using (IMagickImage img1 = new MagickImage(Path.Combine(fullpath, IMAGE1)))
{
using (IMagickImage img2 = new MagickImage(Path.Combine(fullpath, IMAGE2)))
{
using (IMagickImage imgDiff = new MagickImage())
{
img1.ColorFuzz = new Percentage(fuzz);
CompareSettings settings = new CompareSettings()
{
Metric = ErrorMetric.Absolute,
LowlightColor = MagickColors.Blue
};
double diff = img1.Compare(img2, settings, imgDiff);
imgDiff.Write(result);
}
}
}

Windows 10 Universal App custom map

I want to create an app for airplane navigation. Since for pilots the Bing maps are useless I need to create my own map a texture of an aeronautical map.
I couldn't find any clue how to start on this. Is there an SDK for Bing maps where I can create my own texture/overlay?
Do I need to start from rock bottom and create a picture and change its position so the relevant part is in the visible area of the device?
I need the following features:
Show current position on the map.
Add some custom POIs via coordinates
After quite some research I figured it out myself.
Here is most of the code needed if you have the same scenario
Uri format:
"https://webserver/tiles/{zoomlevel}/{x}/{y}.png";
private void InitMap()
{
_gps = new Geolocator();
pointBuffer = cologne;
image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/images/airplane.png"));
MyMap.Style = MapStyle.None;
//Setup Icao Layer
_icaoTileSource = new MapTileSource();
var _tileLayer = new HttpMapTileDataSource();
_tileLayer.UriFormatString = IcaoUri;
_icaoTileSource.DataSource = _tileLayer;
MyMap.TileSources.Add(_icaoTileSource);
//Setup VFR Layer
_vfrTileSource = new MapTileSource();
var _vfrtileLayer = new HttpMapTileDataSource();
_vfrtileLayer.UriFormatString = VfrUri;
_vfrTileSource.DataSource = _vfrtileLayer;
//Setup Low Level Layer
_lowlvlTileSource = new MapTileSource();
var _lowlvltileLayer = new HttpMapTileDataSource();
_lowlvltileLayer.UriFormatString = LowLvlUri;
_lowlvlTileSource.DataSource = _lowlvltileLayer;
airplane = new MapIcon()
{
Title = "My Position",
Image = image,
Visible = true,
Location = cologne,
NormalizedAnchorPoint = new Point(0.5, 0.5)
};
_tileLayer.AllowCaching = true;
MyMap.MapElements.Add(airplane);
systemSetCenter = true;
MyMap.Center = cologne;
MyMap.ZoomLevel = 10;
_vm.ZoomLevel = MyMap.ZoomLevel;
MyMap.ZoomLevelChanged += (s, e) =>
{
if(s.ZoomLevel > maxZoomLevel)
{
s.ZoomLevel = maxZoomLevel;
}
_vm.ZoomLevel = s.ZoomLevel;
};
}

how to get image file type from ios gallery Titanium Appcelerator

I want get the name of the image type like i selected .png ,.gif ...etc,I need to get the name of the selected from iOS gallery.For that i am using the following code snippet.
Titanium.Media.openPhotoGallery({
success:function(event)
{
var cropRect = event.cropRect;
image = event.media;
if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO)
{
var newImageName = new Date().getTime() + ".jpg";
//var newImageName = new Date().getTime();
var filename = Titanium.Filesystem.applicationDataDirectory + "/" + newImageName;
Ti.App.Properties.setString("filename", filename);
newImage = Titanium.Filesystem.getFile(filename);
newImage.write(image);
}
through every file is converted to jpg format .I want get the what every file extension in gallery.

Rails: Mainpulate Image After Upload

In a Rails environment, I want to manipulate an image after it has been uploaded. I do not need to change the image, but I want to present it to the user based on parameters in the URL.
Any suggestions?
It means after uploading completed you need to show image, you can show imaged using javascript and jquery, i have done this in sample project like following way
function showThumbnail(files){
for(var i=0;i< files.length;i++){
var file = files[i];
var imageType = /image.*/
if(!file.type.match(imageType)){
alert("Not an image");
}
var image = document.createElement("img");
var thumbnail = document.getElementById("thumbnail");
image.file = file;
if(file.type.match(imageType)) {
if((thumbnail.hasChildNodes() == true)){
thumbnail.removeChild(thumbnail.firstChild);
thumbnail.appendChild(image);
}else
{
thumbnail.appendChild(image);
}
}
var reader = new FileReader()
reader.onload = (function(aImg){
return function(e){
aImg.src = e.target.result;
};
}(image))
var ret = reader.readAsDataURL(file);
var canvas = document.createElement("canvas");
ctx = canvas.getContext("2d");
image.onload= function(){
ctx.drawImage(image,75,75);
$(".uploadedPhoto").addClass('whiteBG');
$(".uploadtxt").html(file.name);
}
}
}

MonoTouch.Dialog: When no ImageUrl, default image on StyledStringElement

I am setting the ImageUrl of a StyledStringElement, but do not know if the url exists. I'd like to put in an placeholder image that is used until the image is successfully downloaded:
var item = new StyledStringElement(n.Title);
item.ImageUri = new Uri(n.ImageThumbUrl);
I get this now:
Helpful: http://yusinto.blogspot.ca/2012/05/background-image-downloading-with.html
I copied the StyledStringElement to a new StyledStringElementLoader and edited this code:
if (extraInfo.Uri != null)
{ img = ImageLoader.DefaultRequestImage (extraInfo.Uri, this);
if(img==null)
img=myLoaderImagePassedToConstructor;
}

Resources