MolotovCherry / Android-ImageMagick7

Fully featured, latest builds of imagemagick 7 for Android. Featuring a full build of very many libraries (delegates)
170 stars 52 forks source link

Still no Implementation #9

Closed swa00 closed 3 years ago

swa00 commented 3 years ago

Hi,

at first - Thx a lot for your work ... I do not have experience with NDK and i need the Lib only for one operation in my app ( bevel)

But im Sorry , maybe i'm stupid - i followed all instructions with the finished zip from here https://github.com/cherryleafroad/Android-ImageMagick7/issues/4#issuecomment-568859199

i still get no Unsatisfied Link error. Can you pls help me ??

What i have done

a) create a blank project ( androidx , AS 4.1.1) b) copied the whole Source, created a (blank) Jni folder, c) created a libs/arm64-v8a and copied all files from zip above into it d) compile project ( with NO changes of init part in your Mainactivity ) f) added Write permission

When i start the project , the lib will loaded ( System.loadLibrary("jmagick-7");

But the next point fails

java.lang.UnsatisfiedLinkError: No implementation found for void com.wdtec.testapp.magick.Magick.setAppConfigDataDir(java.lang.String) (tried Java_com_wdtec_testapp_magick_Magick_setAppConfigDataDir and Java_com_wdtec_testapp_magick_Magick_setAppConfigDataDir__Ljava_lang_String_2)

Any cool tip as christmas gift for me ? :-)

Thank u very much

MolotovCherry commented 3 years ago

Did you follow the Quick Setup Instructions on the main page, including the section on How to Run the Binary, and the FAQ of Frequently most encountered problems and how to solve them (which includes how to solve the Unsatisfied Link Error)? There's even a link to an example app with the full app folder structure and example code.

By the way, I really don't recommend to use that version. 1) It's old, 2) you probably don't need nor want jmagick, 3) invoking the binary with the commands you want should more than suffice for everything you need, 4) it's harder to to use jmagick rather than just invoking a binary with commands

Also, setting up the NDK to build it yourself is incredibly easy. It's as easy as downloading and installing it from the SDK manager, then you can look at my example app for a build config and app structure. I even included a bat file to start the build process.

d) compile project ( with NO changes of init part in your Mainactivity )

You need to look at and change the code. It's example code meant to be changed and configured according to your needs. It's not build ready. You need to look at the main instructions on the main page and add your ENV variables (btw, all that is done in the code already, so you just need to uncomment/change it and make sure you're using a binary only build -> I realize I'm referencing the binary version, that's because this is the version you should be using).

(Again, you really don't want to use the jmagick version there. It'll make things harder for you when programming. Use the binary code section in the MainActivity.java, I marked the sections. And delete the jmagick section).

And if you want to use the latest code, you'll have to build it yourself, but like I said before, there's some Quick Start Instructions on the main page for that, and it's as easy as copying my app folder, looking at and changing the code, installing NDK from the SDK manager, and putting the project in the JNI folder and starting the build.

I'd also need to see your entire project to tell you what's wrong, because there's too many points of failure.

Lastly -> There are some old binary builds in the release section, you can use it for initial testing to see if you got it right (use the static build if you want it to be the easiest for you). But ultimately, I suggest you use the most up-to-date sources. And again, literally anything you want to do can be done in a binary build, plus you get official documentation from the Imagemagick website for it (good luck finding documentation for jmagick)

swa00 commented 3 years ago

Dear Cherry ,

I'd also need to see your entire project to tell you what's wrong, because there's too many points of failure.

at first - THANK you very much for your (long) answer and your time you spent for it. While i try to understand completly your answer and get into it, as attach my cleaned project https://my.hidrive.com/lnk/x6gmmusi

i think also, that i do not understand correctly , whats the different between the versions and what IM source-code has to use. to build

Again thank you very much for your time.

swa00 commented 3 years ago

.

MolotovCherry commented 3 years ago

i think also, that i do not understand correctly , whats the different between the versions and what IM source-code has to use. to build

As usual, new versions offer bug fixes and newer features.

MolotovCherry commented 3 years ago

So some things I noticed with your project.

Uncomment section:

        /* CODE FOR SETTING UP BINARY USAGE
           Obviously you will need to check whether you already set this up or not
           You don't want to run this every time you start your app
           You can use Android SharedPrefs to keep track of it

Delete section:

        // FOLLOWING CODE EXAMPLE BELOW IS FOR JMAGICK ONLY. IF YOU DON'T USE JMAGICK, 
        // USE THE BINARY CODE ABOVE ONLY
....
    /// END JMAGICK SECTION

Uncomment section

    /* AsyncTask example code used for executing the binary
       If you don't run the binary on a separate thread, your UI will freeze
       Adapt it to your needs

... And so on

P.P.S. If you look closely at the example app, there's a binary and lib already in the folders. You could just copy that example app verbatim, uncomment the binary java code (and delete the jmagick section), and it'd probably work out of the box

swa00 commented 3 years ago

Thank you - very much :-)

I started to get into it - this will take the night and i will give you the feedback (Hopefully happy ..... or i will change my proffession next year)

MolotovCherry commented 3 years ago

Java_com_wdtec_testapp_magick_Magick_setAppConfigDataDir

This error means that Java is looking for the native function in JNI, but it can't find it. Notice the path com_wdtec_testapp_. In short, your packages are in the wrong places.

My C functions are named Java_magick_Magick_setAppConfigDataDir, which you can see the Java package path here magick_Magick. Reference

So, if you fix your package locations (and the package statements and import statements), it'll fix that error

swa00 commented 3 years ago

This error means that Java is looking for the native function in JNI, but it can't find it. Notice the path >>com_wdtectestapp. In short, your packages are in the wrong places. So, if you fix your package locations (and the package statements and import statements), it'll fix that error

Oh, my, god !!!! This was the goal and its working !!! Note for me in the future : Leave it like it is and don't think too much :-)

@cherryleafroad

Thank you very very much for your help. i wish you and your family a nice christmas time and please keep healthy

MolotovCherry commented 3 years ago

You should know that the jmagick version is probably unreliable too, I wouldn't trust it much to do what it should. jmagick was already pretty much defunct before I even included it here. The only way to get a good jmagick version would be to do a complete rewrite from the ground up, but unfortunately after writing thousands of lines of C code, it was too much work for 1 person *facepalm

swa00 commented 3 years ago

yes you wrote this sometimes above .... and i'm a pure "c" developer - the work ist too much ...... But as i see it , its the only "usable" Imagelib to do simple processes.

in my case, i only need a bevel function like "EmbossMaskFilter" from the original Google API. But this filter was removed ( deprecated ) since API 28 without any replacement or comment from Google. (How often at google :-()

Therefore i tried OpenCV and ImageMagick . But if you have any other alternative , or idea - let me know.

MolotovCherry commented 3 years ago

I mean the binary version. It's much easier to do something like what you what from the commandline ;) You don't have to give up this imagemagick to go for the binary version. If the jmagick API was stable though I'd have no issue saying it may be better (although maybe a bit of work figuring out the programming commands, but nonetheless better). Little tiny bugs or problems may creep up on you without you knowing.

For example, I made something using it, and it wouldn't get transparency right even though it works in the commandline. C coding wasn't right.

Therefore i tried OpenCV and ImageMagick . But` if you have any other alternative , or idea - let me know.

At the time of project creation, there was a surprisingly lack of any good image editing tools for Android (or they were horribly outdated). That's why I made this one. As you say, it's the only "usable" one.

swa00 commented 3 years ago

i also found something in this direction

https://github.com/thenewcircle/renderscriptimaging

Its working (and fast) , but you have to step deeply in impageprocessing from scratch , to implement all basic functions - same work to re-develop any c-library

swa00 commented 3 years ago

Beside Note : Playing with your implementation , i found out that an Android - bitmap operation is missing. e.g getting the BGRA pixels and transfer them to (int) ARGB. (or just get an Bitmap Object during runtime)

Ref : https://github.com/paulasiimwe/Android-ImageMagick/blob/master/jni/magick_MagickBitmap.c

MolotovCherry commented 3 years ago

Beside Note : Playing with your implementation , i found out that an Android - bitmap operation is missing. e.g getting the BGRA pixels and transfer them to (int) ARGB. (or just get an Bitmap Object during runtime)

Ref : https://github.com/paulasiimwe/Android-ImageMagick/blob/master/jni/magick_MagickBitmap.c

Yet another thing missing from the official project. Another example why I don't trust jmagick all that much, as its API is incomplete and lacking (also bug prone). If you feel like getting the src compiling though, adding that file to the build wouldn't be that hard for you.

Just update the build file to include the src, then throw in the magick java src. (and remove the loadlibrary, we already do that).

swa00 commented 3 years ago

Thx a lot :-)

in the moment i'm trying to figure out , how to setup the system correctly to use NDK . As i wrote above , i never played with NDK .

Do you have time to recomplie the binaries and place them here as ZIP ? (If not - no problem - it just saves time - it is only a question)

MolotovCherry commented 3 years ago

I don't - I haven't done this project in a long time and don't have things set up anymore. But if you encounter errors and need additional help, feel free to let me know and I'll help you out. I'm closing this issue as the original problem is solved.

swa00 commented 3 years ago

Using the new NDK 22.070, you have to change several things

a) /MagicCore/memory.c -> function AcquireAlignedMemory_STDC (Line 252)

b) Batchfile needs some changes

Full Example ndk-build --output-sync=none NDK_PROJECT_PATH=[YOUR_PATH_TO_Android-ImageMagick7-master] NDK_APPLICATION_MK=Application.mk APP_BUILD_SCRIPT=Android.mk NDK_OUT=../build/ NDK_LIBS_OUT=../jniLibs -j 4