Xamarin PCL FFImageLoading: How to get the image without using CachedImage View - xamarin

Can we get the bitmap directly from FFImageLoading? I know i can use CachedImage View but I am currently using NControl and NGraphics to do custom drawing with touch events

ImageService.Instance.LoadUrl(urlToImage)
.Into(nativeImageView);
OR
var drawable = await ImageService.Instance.LoadUrl(urlToImage)
.AsBitmapDrawableAsync();
var image = ImageService.Instance.LoadUrl(urlToImage)
.AsUIImageAsync();

Related

Rendering SF Symbols with NativeScript using UIImageView

I would like to use SF Symbols in a NativeScript based app (using svelte native but I guess this should work independent of that).
If I understand this guide to SF Symbols correctly then I can get a view with a symbol like this in Swift:
let image = UIImage(systemName: "star")
let imageView = UIImageView(image: image)
translating into NativeScript like this (see this question):
let image = UIImage.systemImageNamed("star")
let imageView = new UIImageView({ image: image })
Specifically, I would like to render this inside the actionBar, i.e. an actionItem.
What I am struggling with is how to get this into an own component or finding a NativeScript component that would render this view. Or am I on a complete wrong path?
Help is very much appreciated. I am just getting started with NativeScript and I am sorry if this seems like an obvious question.

How to draw a text on an image and how to use this image as my custom pin icon?

How to draw a text on an image and how to use this image as my custom pin icon?
I use the official code in the https://developer.xamarin.com/guides/xamarin-forms/custom-renderer/map/
I can use the custom pin image as an icon to replace the standard google map pin, but I want to add text on this customized pin, then use my new pin (with the text) to my new customized pin icon.
Here is the code I used now
foreach (var pin in customPins)
{
var marker = new MarkerOptions ();
marker.SetPosition (new LatLng (pin.Pin.Position.Latitude, pin.Pin.Position.Longitude));
marker.SetTitle (pin.Pin.Label);
marker.SetSnippet (pin.Pin.Address);
marker.SetIcon (BitmapDescriptorFactory.FromResource (Resource.Drawable.pin));
}
so the maker SetIcon this method to get custom pin icon on my Rouscoure.Drawable folder. In this folder I stored my pin.png image.
I am struggling to draw text in my original pin image. Then, I also don't know how to use SetIcon or InvokeIcon to load my new image if I succeeded add text on my pin.
The main idea is to create a canvas first, then create a paint. After that combine those two together.
There are a lot of Java sample when you google it. The only thing you need to do is how to convert it to Xamarin.Android. It should be easy.
Here is the sample:
https://forums.xamarin.com/discussion/comment/236649/#Comment_236649

How to debug canvas in browser?

How to debug canvas?
It's loading bunch of rotating images in canvas. I want to check what images they are. But firebug shows nothing but the canvas tag.
Is there any way to find out what these canvas pre-loaded images are so I can download them?
You can check the new Firebug feature of 3D view of the page (canvas, div, ...).
You can place debugger; in your javascript code, so the debugger will automatically stop there.
Images drawn to canvas elements are loaded by javascript e.g.
var img = new Image();
image.onload = function(){ draw on canvas };
img.src = "image url";
You could try searching the JS source for .jpg or .png references, etc.

easelJS IE9 bitmap not loading

I'm having trouble using easelJS to render Bitmap in IE9. Every other browser renders the image fine, but IE9 canvas is blank. I even tried preload the image in a hidden div and it still doesn't work. here's my code, help please!
function init(){
var canvas = document.getElementById('myCanvas');
var stage = new createjs.Stage(canvas);
var ship= new createjs.Bitmap(ship.png);
stage.addChild(ship);
}
You need to call stage.update() after adding the child. Also, you'll need to wait until the image is fully loaded. Check out PreloadJS, by the makers of EaselJS to help you handle this.

WP7 background blur effect

I need to know, which is the best way to blur the background of the Windows Phone 7 app to concentrate the user's attention on a "always on top" popup window.
My idea is:
Make an in-memory screenshot of the background grid (by turning it into a freezable or something).
Add an image that overlaps the background grid, but is below (with the z-index) the popup.
Still I doubt I will be able to overlap the application bar.
At this point, if you have a solution, please advise.
A few pointers for you ...
Unfortunately the Silverlight BlurEffect and other Bitmap effects didn't make it into Window Phone 7, so you will have to implement the blur yourself. This is actually pretty simple, just use a Gaussian Convolution Filter.
To achieve this effect you can capture the visuals of your application into a WriteableBitmap, manipulate the image to create your blur, then overlay this image over your application using a PopUp. I did something similar in a blog post I wrote about fly-out text animations here:
http://www.scottlogic.co.uk/blog/colin/2011/04/metro-in-motion-3-flying-titles/
Find your root visual as follows:
var rootElement = Application.Current.RootVisual as FrameworkElement;
Add a copy of this UI into a popup as follows:
_backgroundMask = new Rectangle()
{
Fill = new SolidColorBrush(Colors.Black),
Opacity = 0.0,
Width = rootElement.ActualWidth,
Height = rootElement.ActualHeight
};
_popupCanvas.Children.Add(_backgroundMask);
_targetElementClone = new Image()
{
Source = new WriteableBitmap(element, null)
};
_popupCanvas.Children.Add(_targetElementClone);
And show it:
_popup.IsOpen = true;
I'll leave you to work out how to blur the background!
As an aside, your will not be able to overlay or capture the application bar visuals. Hide it before performing this transformation.
Finally, blurring the background isn't really very 'Metro'. Are you sure you want to do this?
Instead of blurring just use a semi transparent layer over the top of the page.
You should hide the application bar before trying to create such an effect as you won't be able to place anything on top of it.

Resources