If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
MinGW / NetBeans IDE DLL for Bitmap
2 posts
• Page 1 of 1
MinGW / NetBeans IDE DLL for Bitmap
Hi,
Has anyone created a DLL for Bitmap manipulation using the MinGW / gcc / gc++ / NetBeans IDE as outlined on the Flowstone Guru site?
The MinGW / gcc / gc++ / NetBeans IDE are the preferred method of making DLL's for Flowstone currently according to Flowstone Guru.
I have used (MinGW / gcc / gc++ / NetBeans IDE) to create DLL's doing other functions (audio delay, format manipulation etc.) but have not used it for Bitmap manipulation.
The Flowstone Example DLL has an example (and I have tested and it works) but they used Visual Studio 2008 to compile the DLL - unfortunately that version of Visual Studio is long gone... VS 2015 now...
Also, I noticed something in the "Helper Macros"
Notice the BYTE* in the GETBITMAPDATA (#define)... does C or C++ allow the use of BYTE* ? should that be int* ?
Any help or examples using the MinGW / gcc / gc++ / NetBeans IDE for Bitmap manipulation would be greatly appreciated.
Aron
Has anyone created a DLL for Bitmap manipulation using the MinGW / gcc / gc++ / NetBeans IDE as outlined on the Flowstone Guru site?
The MinGW / gcc / gc++ / NetBeans IDE are the preferred method of making DLL's for Flowstone currently according to Flowstone Guru.
I have used (MinGW / gcc / gc++ / NetBeans IDE) to create DLL's doing other functions (audio delay, format manipulation etc.) but have not used it for Bitmap manipulation.
The Flowstone Example DLL has an example (and I have tested and it works) but they used Visual Studio 2008 to compile the DLL - unfortunately that version of Visual Studio is long gone... VS 2015 now...
Also, I noticed something in the "Helper Macros"
- Code: Select all
#define GETFRAMESIZE(p) p ? *((int*)p) : 0
#define GETBITMAPWIDTH(p) p ? *((int*)p) : 0
#define GETBITMAPHEIGHT(p) p ? *((int*)p+1) : 0
#define GETBITMAPCHANNELS(p) p ? *((int*)p+2) : 0
#define GETBITMAPDATA(p) p ? ((BYTE*)p+12) : 0
#define GETBITMAPBYTES(p) p ? *((int*)p) * *((int*)p+1) * *((int*)p+2) : 0
#define NEWINTARRAY(p,n) if(n>0) { *((int**)&p)=new int[n+1]; ((int*)p)[0]=n; }
Notice the BYTE* in the GETBITMAPDATA (#define)... does C or C++ allow the use of BYTE* ? should that be int* ?
Any help or examples using the MinGW / gcc / gc++ / NetBeans IDE for Bitmap manipulation would be greatly appreciated.
Aron
-
aronb - Posts: 154
- Joined: Sun Apr 17, 2011 3:08 am
- Location: Florida, USA
Re: MinGW / NetBeans IDE DLL for Bitmap
aronb wrote:The MinGW / gcc / gc++ / NetBeans IDE are the preferred method of making DLL's for Flowstone currently according to Flowstone Guru.
That's only the preferred method of the author of that post, nothing official.
I personally would recommend you use Visual C++.
aronb wrote:The Flowstone Example DLL has an example (and I have tested and it works) but they used Visual Studio 2008 to compile the DLL - unfortunately that version of Visual Studio is long gone... VS 2015 now...
The version of Visual Studio and/or the visual c++ compiler that you use doesn't matter.
You can use VS2015 or VS2017 without a problem.
aronb wrote:Notice the BYTE* in the GETBITMAPDATA (#define)... does C or C++ allow the use of BYTE* ? should that be int* ?
If you are building a dll you would usually be including the windows.h header, which defines BYTE as unsigned char.
Here's a simple example for flipping a bitmap, but I only tested with VS2017.
- Code: Select all
#include <windows.h>
#include <new>
#include <cstring>
extern "C"
BOOL WINAPI DllMain(HINSTANCE, DWORD reason, LPVOID) {
switch(reason) {
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
return TRUE;
default:
return FALSE;
}
}
class FSBitmapView {
unsigned char* bytes_ptr;
bool m_allocated;
FSBitmapView(unsigned char* ptr, bool allocd) : bytes_ptr(ptr), m_allocated(allocd) {}
public:
static FSBitmapView from_input(int input) {
FSBitmapView view(reinterpret_cast<unsigned char*>(input), false);
return view;
}
FSBitmapView() : FSBitmapView(nullptr, false) {}
bool allocate_for_output(int& output, int width, int height, int channels) {
deallocate();
bytes_ptr = new(std::nothrow) unsigned char[12 + width * height * channels];
if(bytes_ptr != nullptr) {
this->width() = width;
this->height() = height;
this->channels() = channels;
m_allocated = true;
output = reinterpret_cast<int>(bytes_ptr);
}
return bytes_ptr != nullptr;
}
int& width() {
return *reinterpret_cast<int*>(bytes_ptr);
}
int& height() {
return *reinterpret_cast<int*>(bytes_ptr + 4);
}
int& channels() {
return *reinterpret_cast<int*>(bytes_ptr + 8);
}
unsigned char* pixels() {
return bytes_ptr + 12;
}
unsigned char* pixel_at(int x, int y) {
return pixels() + y * width() * channels() + x * channels();
}
bool ok() const {
return bytes_ptr != nullptr;
}
void deallocate() {
if(m_allocated) {
delete[] bytes_ptr;
bytes_ptr = nullptr;
}
}
~FSBitmapView() {
deallocate();
}
};
static FSBitmapView bmp_out;
extern "C"
__declspec(dllexport)
void flip_bitmap(int num_params, int* inputs, int* outputs) {
if(num_params < 1 || inputs == nullptr || outputs == nullptr)
return;
auto bmp_in = FSBitmapView::from_input(inputs[0]);
const int w = bmp_in.width();
const int h = bmp_in.height();
const int channels = bmp_in.channels();
if(!bmp_out.allocate_for_output(outputs[0], w, h, channels)) {
return;
}
for(int y = 0; y < h; ++y) {
for(int x = 0; x < w; ++x) {
for(int c = 0; c < channels; ++c) {
bmp_out.pixel_at(x, h - (y + 1))[c] = bmp_in.pixel_at(x, y)[c];
}
}
}
}
- TheOm
- Posts: 103
- Joined: Tue Jan 28, 2014 7:35 pm
- Location: Germany
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 47 guests