Using android palette class in desktop java application - java

Android developers have created a great class to isolate colors from an image
https://android.googlesource.com/platform/frameworks/support/+/refs/heads/master/v7/palette/src/android/support/v7/graphics/Palette.java
However I could really use this in a desktop application. I tried ripping the class from the library (as recommended to me , during a Devox java conference by one of the android devs) but he probably didn't realize I would have to drag half of the android library with me then eg: Bitmap, Color
Does anyone know of a tool that might be able to strip the classes I need retroactivly from the library, or give me a better way to solve my original problem, a java class that will give me the dominant colors of an image together with their inverse and adjoining colors ? I can't write it from scratch cause we just don't have the budget/time to do that :(

I stumbled upon your question and I also found this lightweight library on github that is a port of one of the javascript libraries that Chris Banes references in the blog post mentioned above.
It's pretty good at extracting the primary color for images quickly. I would still love it if someone had a way to extract something like what android calls the "vibrant" color. Ideally I would love a way to mimic exactly what happens in the android library so i could have a seamless experience between my android, desktop, and ios experiences. I still haven't found that one yet.

Another Java port - https://github.com/trickl/palette. I wrote this one myself (I was unaware of the existence of other ports at the time). It's a pretty direct port and includes a bunch of the original tests.

There is this Palette ported library. You can use it in your Gradle based java project by adding jcenter() to your repositories and the next dependency into your build.gradle file.
dependencies {
...
compile "com.loyalsound:iris:1.1"
}

Related

A gradle plugin to replace RoboVm for libgdx?

I had been using RoboVM on libgdx. I recently updated everything I had been using and had to face the fact that RoboVM is winding down.
To be honest, I was a beginner when I started LibGDX and never needed to pay attention to backend stuff. I got started with couple youtube tutorials and was I fine until recently.
For that reason I am trying to understand what is going on, and looking for a way around. I had come across with BugVM and the list on the following link: http://www.badlogicgames.com/wordpress/?p=3925
However BugVM is not decently documented yet, and I am having trouble understanding how to use any items on the list given in the link.
Could you briefly explain how do I integrate any item on the given list, or could you just push me in the right direction so that I could start learning by myself? Or could you suggest me a simple RoboVM like plugin which would work on IOS, Android and Desktop as RoboVM did? My intention is to create an application that will work on Android, IOS and Desktop (I was simply running DesktopLauncher before to test my code. Now I get "RoboVM has not been licensed for this machine." and looking for a long term solution).
At this point I am completely lost and I am eager to learn. I just need some guidance as I am trying to learn it all completely by myself for now. Any help/suggestion/explanation is very much appreciated, and I am pretty sure your response will be useful to other beginners in the future as well.
First of all the so called solution in your link have been changed since then:
http://www.badlogicgames.com/wordpress/?p=3934
I recommend download the latest gdx-setup.jar for libGDX 1.9.3 or later:
https://github.com/libgdx/libgdx/wiki/Project-Setup-Gradle
Create a new libGDX project with ios and ios-moe subprojects enabled and then look how those 2 ios backend are implemented.
After that eihter copy your old project code into a fresh setup libgdx project or rebuild the basic setup within you old code.

Do you know if it's possible to compile a libgdx in Android (in an Android phone) without compiling it in native JAVA?

I'm trying to begin programming with libgdx (in Windows XP with Eclipse for JAVA - Android) but, as every begining, nothing is clear and every doubt is a big problem.
I have found some tutorials about how to begin to programming with libgdx, but every tutorial found says the same: you must create a PC project for compile the native JAVA code and then create another project for Android who needs the PC project.
It's possible to do it in a easier way (all in only one Android project)? If it's possible, how? It would be really slower? I run my Android projects in my device (a Motorola G) and it seems pretty fast.
All (kind) responses will be appreciated. Thank you.
Are you using the project generator? http://code.google.com/p/libgdx/wiki/ProjectSetupNew
You could use that and simply ignore the non-android projects it creates ,even delete the other ones you don't plan to use (not the main java one though) and run it via an android emulator/device.
You will probably still have to keep the main java project, libgdx is geared towards people that want to compile to multiple devices.
It's been over year since i've used libgdx and i don't recall this being one of the issues i had with it.
The easiest way I find is to actually just put a main method class in your libgdx project. I have a wrapper project for android that invokes my libgdx project but if you look at the example in superjumper source in github you can see they just put a main method class within their libgdx project.
The android project then just delegates to this project.
Consider though, if you do run it directly from a project, you'll need to code in keyboard cursor keys which is pretty easy, you can follow the superjumper example here line 138.

Build Android native library with Adobe Air

I'm currently working on an Android application built with Adobe Air sdk, in AS3. I was wondering if it's possible to compile a kind of UI library that I can import in a Android native application (Java). Basically, I would like to build my UI with Adobe Air, but the main part of my application with Java, the native way.
What I have in mind is to convert the adobe air-generated APK into a Jar file I would import in the native application project, and call some functions that display something on the Screen.
Is it possible? I think it may be possible, because when I don't import Adobe Air SDK in the application, I must install Adobe Air application with the Play Store to make my application working. I don't find lot of things on Google about that :s.
Thank you for your help.
Yes it can be done (in theory), but hold on to your hat, it's a bumpy ride!
I see it is a very old question, with a new bounty (the questioner has not logged on for 3 years!), but here we go...
This method goes to the heart of how android java apps are constructed and run (i.e. DEX, so it will work with adobe-air or ANYTHING, it is fundamental [general method]). (by the way you use the word native in a confusing way, native is commonly understood to mean the JNI (c++) library element of an app).
You say:
"What I have in mind is to convert the adobe air-generated APK into a
Jar file I would import in the native application project, and call
some functions that display something on the Screen."
Android programs are compiled into .dex (Dalvik Executable)[now called ART but binary compatible] files,
which are in turn zipped into a single .apk file on the device (with other things like the manifest and resources). (unzip a .apk and look inside).
A .jar file contains DEX files (zipped). (unzip a compiled .jar and look inside).
I have done some work like this before, here's a link to a tutorial and coding examples [tested by me] (in android studio + gradle) [custom build elements are usually needed (I also give an ant example)].
See my stack-overflow answer Dynamic loading of DEX files
This in theory answers your question, but it's fundamental stuff, complex and has limitations that make it hard to code and maintain (resources are a real pain in the a**e).
Question: This all seems very complicated and hard !
Yes it is ! It is an increadably silly an difficult thing to do! That is why we invented cross platform frameworks, (and for web based code javascript/css/html5...). Failing that PORT the code.
I'm more of a Flash/AS3 coder than Java so can't give you a full answer but...
A better approach might be to just render your SWF-based User Interface itself via Java code (as opposed to compiling SWF into APK format then trying to embed Flash APK inside Android APK).
This way your SWF can also communicate with Java functions (via AS3's external Interface class). Making it easier to trigger Java functions when a button on the SWF U.I is pressed etc..
You just have to find an SWF render library for Java.
Maybe check out SWFTools. Particularly the SWF Class looks promising. I have not tested this library but it might help you.
I am not a Adobe AIR developer at all, however, I have developed a few Android App with both native environment and with some kind of framework (specifically PhoneGap). So, may this can help you.
I don't think that there would be any tool which could directly convert mobile apps build using frameworks like Adobe AIR, PhoneGap or any other HTML5 based framework to a native Android app because technically it is very difficult and unfeasible to do a proper mapping between each and every element of HTML5 (or Flex element in your case) to a corresponding native control or logic. The best you can do is use plugin mechanism provided by your framework to interact with Java and vice-versa and basically that is why the framework is there. For most of HTML5 based frameworks there is a plugin mechanism which allows developer to interact with native functionality (like Background Services, Activity or any other native resource). Even these frameworks are build using the same modular or plugin based approach and there major functionality (accessing Camera, Audio, SD Card etc native resources) works like this. We have to enable that feature before using that in our app.
So, look for plugin type of mechanism in Adobe AIR.
Hope this helps.
Maybe this is a dirty way to help you, but you can :
Install the adobe air program in one computer
Copy the files of the install folder of the adobe air program
Embed all this files in the java application
Install the java application
Save the adobe air files in one folder
Start the adobe air with java (like you will do it with the console, a simple call to YourAirApp.exe)

How to take a picture of in panaroma mode?

I want to make an application that allow the user to take a picture of text either from android device Gallery or from android Camera application in a Panorama mode .But i can not find any source or tutorial to do this.How can i do this in my application? how to make an application that take picture from android camera application in a panaroma mode?
Thanks in advance.
I don't know if it's still actual for you, but hope it will be helpful for someone.
Panorama feature is already implemented in standard android camera at least since Android 4.0 (perhaps it was available in even earlier versions but I'm not sure, you can check it), so since source code is open for everyone, it might be the easiest way just to copy required functionality.
Although you can download source of apps from https://android.googlesource.com/ (you want LegacyCamera or Camera), you can't just open project of any standard app in Eclipse or other IDE. For example, LegacyCamera depends on Gallery2 and other dependences that might be hard to be resolved.
I spent several days trying to move panorama feature to separate project. You can download it from here: https://github.com/yankeppey/PanoramaSample . Several remarks:
Functional core (creating one panorama image from several ones, progress notices, etc) is on native part.
I used java code from from LegacyCamera which was used in Android 4.0-4.1, not 4.2, because it was significantly easier for me. Native part is taken from 4.2, it has only minor changes inside and almost the same JNI interfaces.
This project is just to help you move panorama feature to your own app, it's not like kind of library, don't expect clean code without bugs, it's just pretty dirty and buggy project. If I have time I'll try to make it cleaner, but there is no warranty :)

Implementing downloadable code and content plugins for Android

I'm kinda new to a plugin development in Java and Android, so I wanted to ask this basic question.
Consider that I have some framework which has some Factory which can produce certain classes - these classes perform some plugin-like functionality. I want to implement a plugin system that would be able to somehow download new plugins from some server and make them available for that Factory for creation.
And the basic requirements for plugin is:
it contains code by implementing some common interface
it contains resources (for example drawables)
For example this might be a "shapes" drawing app. each plugin has code to draw() a shape, optionally by using bitmap for filling that shape - in this case bitmap is supplied with a plugin as a resource.
How should I go about this? Any pointers to google search terms and hints are appreciated, thanks :)
I don't think you can do this on Android, because of security restrictions. It is very likely that your only option is to distribute plugins as separate application in the Market (like Doplhin browser does).
However, the problem to be solved is: how are you going to discover those plugins? To answer this we would need to know how do you intend to use those plugins. If should be easy if your plugins are plain old activities.
I found this post for you: http://mylifewithandroid.blogspot.com/2010/06/plugins.html

Categories

Resources