How to resize image file on Xamarin.forms. (+ writeableBitmap package can't be added) - xamarin

I'm making iOS and Android app using with Xamarin.forms. (PCL project)
I need to resize my image file from 'MediaFile class' that is returned from 'CrossMedia.Current.PickPhotoAsync ()'.
What's your best way to do it?
and I have searched long time and noticed that many people uses 'writeableBitmap'.
But this 'writeableBitmap' nuget package can not be added because Xamarin platform is updated?

I got great answer from here.
https://forums.xamarin.com/discussion/comment/199212#Comment_199212
It's using DependencyService and it works beautifully.
After applied DependencyService, I got a question.
In my thinking, image file is not dependent so why don't we process it just in 'forms' using with SOME image process library in .net? (I'm not a .net developer but I believe that there is many library to process image file)
I suspect that we should have done because we want to use built-in image processing library(like UIKit) so that we could avoid adding new one?
Am I correct?

Related

Flutter Pdf Viewer performance

I'm creating an educational application for poor students who have android devices running on Android 4.1 and above.
I tried lots of packages but
most of them make the app crash and the rest take long to load the file and the application becomes heavy to use.
Is there a package or a way to improve the the performance?
I don't want to convert the pdf pages to images because this will make the size of the app very big to download.
These are the packages that I used:
flutter_full_pdf_viewer: ^1.0.6
pdf_image_renderer: ^0.5.0
advance_pdf_viewer: ^1.2.2
flutter_cached_pdfview: ^0.3.5 #min API Level 20
printing: ^5.2.1
pdf_flutter: ^1.1.4
flutter_pdf_viewer: ^0.6.1
native_pdf_view: ^4.0.1
flutter_pdfview: ^1.1.0
`
If you are facing issues with every pdf viewer then my suggestion would be to not use your app pdf viewer instead if possible you can use the default pdf viewer which generally comes preinstalled in devices. And you would need a way to know if a phone has an app that can open pdf files or not and in case it is not there then use your app pdf viewer.
The second option would be to split the pdf files into multiple pdf files like chapters, etc. I think this option is very much viable.
Also, you can try this package syncfusion_flutter_pdfviewer. I'm using it as of now and it is good.

Loading PCL sourced HTML page in Cross Browser project (Xamarin)

I am using Xamarin to support
Android
iOS
Windows 8.1
WPF
I can create a PCL project that each of those platforms can see from their platform specific project.
What I want to be able to do is host a HTML page and associated javascript files in the PCL.
All the examples I have seen for loading Local Html files are when there is a copy of the HTML in each platform specific project. I don't want 4 copies of the HTML I want one copy in the PCL.
Can this be done?
We tried to do the same thing a few months ago and as far as I remember we couldn't. The solution for us to make it work was downloading (or extracting in your case) html files to the local directory for each platform using PCLStorage nuget and load directly from local path with custom renderers.
We used custom renderers for each platform for WebView instead of crossx webview. One thing to note that instead of using UIWebView you must use WKWebView if you're targeting iOS9+.
Simply pass your main directory of html files to each renderer and try native controls to use local content. Unfortunately xamarin's crossx WebView does not provide flexible actions when it comes to local content.

Accessing resources XML from another library project in Xamarin.Android

I am trying to create a Xamarin.Android Component to send to the Xamarin Component Store, and I need to bundle my Colors.xml with it, so it is accessible to everyone using my component. I am setting the build action for the Colors.xml tp "AndroidResource".
So I created an Android sample application, when I add a reference to my library project's dll, I am able to use the colors defined, my project compiles and it runs, but I get no intellisense on Xamarin Studio. So that would be a bad thing for anyone using my library, as they would not be able to even see that the colors are available to use. You can see in this picture the colors defined are not available in the suggestions box.
If I add the Colors.xml directly into my project, I get Intellisense support, like this:
Is there a way to achieve the same result above when adding just the dll reference? Did I do something wrong or Xamarin.Android/Xamarin Studio doesn't support this kind of scenario?
EDIT: To be clear, I know this is a problem with Intellisense not being able to pick up the values, but is there anything I can do to make it work?

Monodroid Custom UI controls

I want to know where I can get access to the NinePatch images specifically for Monodroid. I want to change the default coloring from blue to orange (if I was doing this in Java it would already be orange).
All I need is to change an edittext so that it's default colors are different. I have seen
http://www.androidworks.com/changing-the-android-edittext-ui-widget
which is really helpful but only as far as vanilla Android is concerned. I tried following the instructions, but I found the standard orange java images, not the Mono ones, which are blue.
Minimum framework is 2.2. I know that I am getting the java images because when I go to C:\Android\android-sdk\platforms there is no android-2.2 folder.
I'm not really sure what you are referring to. Mono for Android does not ship any NinePatch images. Mono for Android simply provides a thin binding over the Java API, it does not do anything custom.
Maybe it is triggered by changing your Android target framework?
I found my answer - and thank goodnesss it did not involve changing the 9Patches!
You can make an xml in the drawable folder which describes your button, textbox, etc. and make a selector with a solid tag, pressed event, etc. (http://developer.android.com/guide/topics/resources/drawable-resource.html)
Then you can set up the colors as a constant set in the Values folder and boom! Solution!

Embed image in code with Visual Studio

I remember reading once that there was a way to embed an image into a code file (e.g. a screenshot or diagram) in Visual Studio, but now I can't find any reference to that feature.
Is this possible to do, or am I imagining things?
EDIT: I don't mean embed the image in the executable, for use at runtime. I mean link or embed it literally in the code, for use by developers.
There is a plug-in for VS 2010 that can do this:
Plug-in
There is also a plugin for VS2012 and VS2013. At this moment installing for VS2013 does not seem to work for me though.
ImageComments extension on GitHub
You can embed images in your binary through the use of the ImageList control, which is typically used to store small icons for list controls, gridviews, etc., but could also be used for storing really any image for any purpose. A better solution would be to include a resource file and store your images there.

Resources