Can I use Android SDK classes in a desktop application? - android

I have some android.graphics.Bitmap data saved to a file that I want to manipulate in a desktop application. The data is generated by a third party application, so I can't modify the app to save the data as png or jpeg.
I am wondering if I can import the android SDK jar into a java desktop project so I can use the android.graphics.Bitmap and android.graphics.BitmapFactory classes? I have tried adding android.jar from the SDK but when I try to call the BitmapFactory.decodeByteArray() method I get a runtime exception ("Stub!").
Please help.
If I can't import the SDK jar, does anybody know the format of the bitmaps that android uses?

The Android SDK is for Android's Dalvik VM, not the the normal JVM, so that is not going to work.
Since it is a bitmap, the data should be stored in a continuous list of Red, Green, and Blue pixels (the order of the colors can vary, there might also be alpha.)
So this might be an image:
[FF][00][00][00][FF][00][00][FF][00][FF][00][00]
Assuming that image was stored in RGB format and was defined as being two pixels wide (the pitch) then it would be a 2x2 px image that represented a tiny red and green checkerboard pattern.
Your app might be exporting the width/height of the image and it might not. If it isn't you'll need to determine the width in order to get a proper image.

Related

Can I use SVGs instead of PNGs to large scale project

We've already built projects like DocuSign in both iOS and Android, we've quite extensive use of documents which is loaded in form of PNGs, where users can quickly move to their selected page (e.g 1 -> 25), so we worked on closely to make it stable and fast but we've requirement to not gets pixelated while zooming (where PNG lack and gets pixelated), so I done R&D on vector base supported in iOS and found that PDF will not fit for our requirement but SVG may fit. But As SVGs aren't natively supported in iOS so
Is it the right decision to use any third party for SVG support in iOS
like https://github.com/SVGKit/SVGKit in large scale projects?
Will memory management will effect I read many links where it
mentioned it's not recommended like
https://www.quora.com/Should-you-use-SVG-files-for-images-in-an-iOS-app
?
Does anybody go through this kind of problem? looking for suggestions and solutions.
NOTE: These images are coming from cloud(our server, google drive, dropbox and One drive)
You can use Vector xml
Right click on rec>drawable folder
select Vector Asset
then select Local file(SVG)
Pick path of svg file
and import this will convert your SVG to the vector xml file, this vector drawable you can use in place of PNG files

SVG not correctly converting to an XML Drawable with a high viewport in Android Studio

I have the SVG here: https://github.com/Tick-Talk/tick-talk.github.io/blob/master/ticktalk-logo.svg
In Android Studio,I right click drawables, new -> vector asset, keep the size as is (as it is already 108dp, the size I need for the app icon), and then import. The resulting XML Drawable is completely incorrect and displays in both android studio and on my phone incorrectly.
Am I doing something wrong, or is this a bug when dealing with high viewport dimensions (the svg has almost 3000 pixels for both dimensions) in Android Studio?
And how can I properly convert this SVG to an XML format without the weird issue I am facing?
Thanks in advance!
The Android vector drawable specification does not support all features of SVG unfortunately. That being said, there are some other online tools you can use to convert SVG to XML, and they usually are pretty good about converting features that are not supported.
This one does a good job of telling you what is not supported, and it can give you some options to try to correct the issues. For example, for your icon, it reports the following:
Warning #1: found clip-path(s) attribute which is not fully supported yet (try enabling support for clip-path below)
Warning #2: stroke-width not found on path one or more times. Defaulting all instances to 1.
It also shows you the converted code.
This one converts, shows the converted code, and shows a preview of your graphic.

Add all sizes of image asset in Android Studio with a PDF or Vector file

In iOS development with Xcode it is really convenient because you can add an image asset or launcher icon with one .pdf file and it generates all the necessary sizes automatically. The .pdf file can be created with Adobe Illustrator or a similar program that makes vector graphics.
Rather than sit there and export every size of icon/image asset one at a time, is there a fast way to add a vector image to Android Studio and have it populate all of the relevant sized folders on its own? Or in general, is there a way to accomplish the same thing in some way?
I have seen other posts where people suggest using an online tool that takes your .png image and lets you download a .zip with all of the different image sizes, but by definition, that method will not result in crisp and high quality image assets. You always want to go from a vector.
is there a fast way to add a vector image to Android Studio and have it populate all of the relevant sized folders on its own?
Use File > New > Vector Asset in Android Studio 1.5 and higher. This will let you import an SVG file. Android Studio will attempt to convert it into a vector drawable resource, with varying degrees of success. If you are using a recent version of the Android Plugin for Gradle (1.5.0 or higher should work AFAIK), the build tools will also generate PNGs from the vector drawables for use on older devices (Android 4.4 and earlier).
but by definition, that method will not result in crisp and high quality image assets
You do not have much of a choice on older devices. There are a few deprecated backports of VectorDrawable floating around that you can try to use, but Google abandoned theirs.
You always want to go from a vector.
Not necessarily. Please bear in mind that not everybody has high-end mobile devices. Rendering SVG or other vector artwork is comparatively expensive, which is why Android did not directly support it (and still does not directly support SVG itself).

How to recognize image which template is stored in the app

It needs recognize icons. For example, the app scans with with phone camera and recognizes one of the icons below and if it recognized then the app performs some action. It recognizes it by comparing with icons stored in the app.
Any libs, manuals, please.
And how to name this task if to search it: optical image recognition? (This is not OCR because recognizing image, not text, right?)
Thank you very much!
how to compare set of images in java using pixel based image comparision metric based on mean squared error?
Image Comparison Techniques with Java
Java library to compare image similarity
Google "java code to compare two images"
Also you can try perform and compare MD5 of both images, but i can't guarantee it will work(depends on your situation and if the files are the same).

Android game Image format

I have a problem with an image for an android game. The problem is not a problem with the code because the code that I use I took from a book (Beginning Android 4 Games Developer).
The problem is this: I know the format that I have to use in android: png, but I don't know the settings for this format that I have to use (like RGB565...). Because if I use simply png, when I run the game the images are not good. So I need someone to explain to which settings I need to use for images for android games.
P.S The software that I used is photoshop. If there is better software for this purpose tell me.
I think there is a strong misconception in your understanding of Android and how it implements graphics. You are not constrained to .png for nearly any of your development. The .png and .9.png are only enforced strictly for managing drawable constants.
Android uses Java and has the capability to utilize nearly any graphical format. In particular native support for .bmp, .png, and .jpg are present for every device and Android OS version. You may even create your graphics in realtime byte by byte.
As for a good image editor, there are a number out there. I often use a combination of GIMP and Photoshop, myself.
Hope this helps,
FuzzicalLogic

Categories

Resources