Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Unity Support? #7

Open
arnebp opened this issue Apr 6, 2018 · 10 comments
Open

Unity Support? #7

arnebp opened this issue Apr 6, 2018 · 10 comments

Comments

@arnebp
Copy link

arnebp commented Apr 6, 2018

Thank you for this wrapper. Excellent work.

You've already taken many important steps in regards to backwards compatibility to support .net 3.5. Taking a few more steps would make this project the standard libjpeg-turbo wrapper for Unity. Worth considering in regards to user adoption as no other project out there supports Unity.

At least 2 issues has to be addressed for this to happen. Usage of IDisposable is not supported in Unity. Usage of System.Drawing is not supported in Unity (extending your usage of CoreCompat/System.Drawing may be the answer).

@qmfrederik
Copy link
Collaborator

@arnebp I'm open to adding support to Unity though I have to admit I have no knowledge about/experience with Unity.

What's the alternative of IDisposable in Unity? Would it be enough to just #ifdef the IDispose interface on the classes but keep the actual Dispose method?

Regarding System.Drawing, the way forward is the System.Drawing.Common package which is the "official" port of System.Drawing to .NET Core/.NET Standard. That package supports Mono/Xamarin as well.

Can you let me know whether you can use System.Drawing.Common on Unity?

@arnebp
Copy link
Author

arnebp commented Apr 7, 2018

Using a System.Drawing backport seems to be key. Using System.Drawing.Common in a correctly structured Unity project seems to work. I put together the attached template Unity project for reference.

JpegTurboTest.zip

@Sklinay
Copy link

Sklinay commented Aug 5, 2019

Hello,

I forked this project to make it compatible with Unity.
https://github.com/Sklinay/AS.TurboJpegWrapperForUnity

You will find in the description a Unity project using this fork.

@sebastian-dudzic
Copy link

sebastian-dudzic commented Dec 9, 2019

Hi! I am trying for 2 days to make turbojpeg working both on android and iOS. Windows and Android are ok, but for iOS i get DllNotFoundException. I have added to Plugins/iOS libturbojpeg.a and libjpeg.a

I have no idea how to make this running. This .a files I have from official jpegturbo site. Version 2.0.3

Could you help me with this problem?

@qmfrederik
Copy link
Collaborator

.a files are used for static linking; but P/Invoke in .NET uses the dynamic linking mechanism.

This means you'll need .dll (Windows), .so (Linux) or .dylib (macOS/iOS) files.

@sebastian-dudzic
Copy link

Unfortunately there are no .dylib files in official binaries.

From what I read now it seems I have to use static linking. - https://docs.unity3d.com/Manual/NativePlugins.html

Maybe I should compile my own wrapper and change [DllImport(UnmanagedLibrary, CallingConvention = CallingConvention.Cdecl, EntryPoint = "tjInitCompress")]

to

[DllImport ("__Internal")]

I have to admit im so confused with all that plugins, dlls etc.

@qmfrederik
Copy link
Collaborator

Sorry, I don't know much about Unity. It looks like @Sklinay and @arnebp got it working, they may be able to give you more detailed instructions.

@sebastian-dudzic
Copy link

They have prepared it but only for Windows/OSx. I need to run it on Android and iOS also. Maybe they will help me :)

@TheBricktop
Copy link

how did You managed to get system.drawing working on android?

@andrewcbolt6
Copy link

@SebaDudzic @TheBricktop @Sklinay Were you able to get it working for Android? Getting errors with Unity not finding the libraries properly on Android when running. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants