01McAc wrote: ↑Wednesday 24th March 2021 3:57pm
stevedee wrote: ↑Tuesday 23rd March 2021 7:37pm
Don't know if you are still interested
...What I can do is just copy and paste the code but...
....I don't understand how a (any) library must be declared. How did you figure that out?
Its better not to just copy
any of my examples...its much better to understand how its working and then write your own code
better than my simple examples!
Here is the process I followed to establish what needed to be declared;
Knowing that libraw supported a C API, I opened Synaptic package manager and searched for libraw (If you also have a Debian/Ubuntu based Linux distro, this will make sense).
Although I had a package called: libraw1394 this was clearly nothing to do with RAW files. The only other package listed (and it was already installed) was:
libraw16 described as
a RAW image decoder library.
Initially I declared in Gambas;
Library "libraw"
Public Extern libraw_init(iflags As Integer) As Pointer
...but when I tried to run libraw_init in my code I got an error, something like;
Code: Select all
Cannot find dynamic library libraw.so
...where file.so is usually the library you are looking for.
So then I tried declaring the library as
libraw16, but got a similar message.
Third-time-lucky when I declared:
libraw:16
This format is basically using ":16" to define a kind of version. I say "kind of" because the actual version is reported as: 0.18.8
...but never let the facts get in the way of celebrating a 'success'
I then checked and verified that I was talking to this library by using the most basic function, declared and used something like this;
Public Extern libraw_version() As String
strVersion = libraw_version()
I covered the declaration of functions from a C API in a recent post:
https://forum.gambas.one/viewtopic.php?p=4051#p4051 but if you have more questions, just ask.
Just how you decide to implement this solution will (I hope) be your choice, as I can't see much point in providing highly polished code. After all, you want to write code, not simply copy-and-paste what others dish up. But I will give a little bit of general advice. As your programs get bigger, it makes sense to take a modular approach.
I've taken my own example and moved the code into a Module called
LibRAW, as the only stuff in a Form class should be code that is directly related to the Form. Here are two simple functions in this module;
Public Function initialisation() As Boolean
'returns True if initialisation is successful
pDataStructure = libraw_init(0)
If Not IsNull(pDataStructure) Then
Return True
Endif
End
Public Function version() As String
Return libraw_version()
End
This makes using the library code in Gambas, more Gambas-like;
Public Sub Form_Open()
If LibRAW.initialisation() Then
Me.Text = "LibRaw version: " & LibRAW.version()
LibRAW.CloseLibraw()
Endif
End
...its a bit like a Gambas wrapper for the C library libraw...
although not a great example.
I hope some of this nonsense helps!
Further reading:-
https://captainbodgit.blogspot.com/2019 ... aries.html
https://gambaswiki.org/wiki/howto/extern
Re the poor TV night: how about a good book or going out for photography (night shooting with available light)? Helping people in the forum here might be a better idea:)
Thanks for the tips.
I'm reading quite a bit at the moment and having a love affair with my 3D Printer. Like most love affairs, its about 50% fantastic and about 50% rubbish.
Its currently a bit too cold for my fragile body to venture out after dark. But I hope to re-build my strength and regain control of my body's thermostat in the very near future!