Hi,
I'm trying to write a function in C++ that goes through all pixels in a bitmap and returns the x,y, and RGBA value of all these pixels. The problem is, I don't know what and how to return the result.
I want to use the returned value in Ruby.
Here's what I have right now:
The goal behind this is to create a palette system. The code above would gather all pixels in the bitmap and once I have this information back in Ruby, I want to assign an index to each color and map the index to the x/y values returned by the code above.
So, how can I do that?
Thanks in advance.
- Dargor
I'm trying to write a function in C++ that goes through all pixels in a bitmap and returns the x,y, and RGBA value of all these pixels. The problem is, I don't know what and how to return the result.
I want to use the returned value in Ruby.
Here's what I have right now:
Code:
extern "C" _declspec (dllexport) BOOL GetMappedPixels(long object){
RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;
DWORD rowsize;
DWORD width, height;
LPBYTE row;
// *********************
// my string or array variable?
long x, y;
if(!bitmap) return false;
width = bitmap -> infoheader -> biWidth;
height = bitmap -> infoheader -> biHeight;
rowsize = width * 4;
row = (LPBYTE) (bitmap -> firstRow);
for ( y = 0; y < (int) height; y++) {
LPBYTE thisrow = row;
for ( x = 0; x < (int) width; x++) {
// *************************
// add xyrgba values to my string or array?
thisrow += 4;
}
row -= rowsize;
}
return colors;
}
The goal behind this is to create a palette system. The code above would gather all pixels in the bitmap and once I have this information back in Ruby, I want to assign an index to each color and map the index to the x/y values returned by the code above.
So, how can I do that?
Thanks in advance.
- Dargor