Anybody want to collaborate to create a library for Bitmap Effects?

Rafael_Sol_Maker

Almighty God Jabu
Veteran
Joined
May 8, 2012
Messages
129
Reaction score
56
First Language
Portuguese
Primarily Uses
RMMV
Good job! Well, I known right now three libraries that works with Bitmaps:

- PRCoders' PRFilter (in portuguese, I love this one!)

- Glitchfinder and Untra's Additional Bitmap Methods (source code avaliable!)

- KGC's KGC_BitmapExtension (in japanese, and worked on Ace too!)

Maybe there's other that I don't remember, with a different set of effects, made for VX, but I don't remember anything about. A good point to start is to do a DLL that does something different and entirely new to Bitmaps.
 
Last edited by a moderator:

Rafael_Sol_Maker

Almighty God Jabu
Veteran
Joined
May 8, 2012
Messages
129
Reaction score
56
First Language
Portuguese
Primarily Uses
RMMV
Sorry for the double post, but... Have you dropped this project? I think a library to help to draw geometry would be a good idea, we already have some that apply filters.

Oh, and wait... We got a new bitmap manipulating library to put in my list!

- Copern's Bitmap Color Functions (already good and I hope it will be improved soon).

See ya!
 
Joined
May 21, 2012
Messages
83
Reaction score
4
First Language
English
Primarily Uses
Just letting you all know, I am still working on this. I've converted much of my code to a dll, and am working on making awesome effects such as rotation blur, radial blur, whirl blur, and a bulge effect. All I have to do now is convert them over to the dll (they take at least a minute each when written in pure ruby). I also made several other effects such as colorize, tint, grayscale, and I'm working on pixelize at the moment.
 

scanti

Warper
Member
Joined
Jan 29, 2013
Messages
4
Reaction score
3
First Language
English
Primarily Uses
Just letting you all know, I am still working on this. I've converted much of my code to a dll, and am working on making awesome effects such as rotation blur, radial blur, whirl blur, and a bulge effect. All I have to do now is convert them over to the dll (they take at least a minute each when written in pure ruby). I also made several other effects such as colorize, tint, grayscale, and I'm working on pixelize at the moment.
You might be interested in the RPG Maker VX Ace DLL SDK I'm working on. I noticed that the RGSS301.dll file exports some functions and they might be of use in a custom DLL file. One export that's really interesting is the RGSSEval function. Basically you can run RUBY code inside your custom DLL with it. :D

If you don't believe me try this script in RPG Maker:

RGSS_Test=Win32API.new('System\\RGSS301.dll','RGSSEval','P','')RGSS_Test.call("puts \"whoa!\"")The console will output "whoa!".

It's a bit odd because the RGSS301.dll functions seemed to be wrapped in a Proc.new{<function>}.call so you can alter an existing local variable but you can't create a new one (if that makes sense).

The really cool thing is that your custom DLL be set up to automatically monkey patch your RUBY code. All you have to do is add the line: DL.dlopen('<dll name>') and everything is setup for the end user.

I've throw together a quick example. Put the BitmapFuncs.dll file in the same directory as the Game.exe file. Add the line DL.dlopen('BitmapFuncs.dll') to initialise the dll. It will automagically add an Invert method to the Bitmap class to invert a bitmap.

You can download the example with source code from here.

Edit: Tidy up some spelling.
 
Last edited by a moderator:
Joined
May 21, 2012
Messages
83
Reaction score
4
First Language
English
Primarily Uses
That looks really interesting. Do you know if that kind of thing would work for the earlier RPG Makers too, or if it's new in VXA?
 

scanti

Warper
Member
Joined
Jan 29, 2013
Messages
4
Reaction score
3
First Language
English
Primarily Uses
That looks really interesting. Do you know if that kind of thing would work for the earlier RPG Makers too, or if it's new in VXA?
I downloaded the RPG Maker XP RTP and it looks like it exports the RGSSEval function as well. Try the script in my previous post, substituting the System\\RGSS301.dll for RGSS102E.dll or RGSS104E.dll to see if the format is the same. It will either work or crash.

The only difference as far as the SDK is concerned is that the XP run-time doesn't export the RGSSGetStringUTF16 and RGSSSetStringUTF16 functions. So as long as you comment out the code for those functions it should work (as long as the format is the same for the other functions).

By the way I've started adding my own functions. You may be interested in a convolution matrix (filter kernel) function. Basically it's the foundation of several filters. It inputs a 3x3 matrix which tells the filter how to sample each pixel. Here's the code:

#define RGSSApi extern "C" __declspec(dllexport)typedef struct { unsigned char red; unsigned char green; unsigned char blue; unsigned char alpha;} RGSSRGBA;typedef struct{ DWORD unk1; DWORD unk2; BITMAPINFOHEADER *infoheader; RGSSRGBA *firstRow; RGSSRGBA *lastRow;} RGSSBMINFO; typedef struct{ DWORD unk1; DWORD unk2; RGSSBMINFO *bminfo;} BITMAPSTRUCT; typedef struct{ DWORD flags; DWORD klass; void (*dmark) (void*); void (*dfree) (void*); BITMAPSTRUCT *bm;} RGSSBITMAP;RGSSApi bool Filter33(unsigned int object, int _11, int _12, int _13, int _21, int _22, int _23, int _31, int _32, int _33, int scale){ #pragma warning (disable:4312) RGSSBMINFO *bitmap = ((RGSSBITMAP*)(object<<1))->bm->bminfo; #pragma warning (default:4312) long width, height; RGSSRGBA *row; RGSSRGBA *rowcopy; long x, y; float red,green,blue; int xm,xp,ym,yp; if(!bitmap) return false; width = bitmap->infoheader->biWidth; height = bitmap->infoheader->biHeight; rowcopy=new RGSSRGBA[width*height]; row = bitmap->lastRow; RGSSRGBA *rowcopyOffset=rowcopy; memcpy(rowcopy,row,width*height*4); if(scale==0) scale=1; for ( y = 0; y < height; y++) { for ( x = 0; x < width; x++) { if(x>0) xm=-1; else xm=0; if(x<width) xp=1; else xp=0; if(y>0) ym=-width; else ym=0; if(y<height) yp=width; else yp=0; red=(float)rowcopyOffset->red*_22; red+=(rowcopyOffset+ym+xm)->red*_11; red+=(rowcopyOffset+ym)->red*_12; red+=(rowcopyOffset+ym+xp)->red*_13; red+=(rowcopyOffset+xm)->red*_21; red+=(rowcopyOffset+xp)->red*_23; red+=(rowcopyOffset+yp+xm)->red*_31; red+=(rowcopyOffset+yp)->red*_32; red+=(rowcopyOffset+yp+xp)->red*_33; red = red/scale; green=(float)rowcopyOffset->green*_22; green+=(rowcopyOffset+ym+xm)->green*_11; green+=(rowcopyOffset+ym)->green*_12; green+=(rowcopyOffset+ym+xp)->green*_13; green+=(rowcopyOffset+xm)->green*_21; green+=(rowcopyOffset+xp)->green*_23; green+=(rowcopyOffset+yp+xm)->green*_31; green+=(rowcopyOffset+yp)->green*_32; green+=(rowcopyOffset+yp+xp)->green*_33; green = green/scale; blue=(float)rowcopyOffset->blue*_22; blue+=(rowcopyOffset+ym+xm)->blue*_11; blue+=(rowcopyOffset+ym)->blue*_12; blue+=(rowcopyOffset+ym+xp)->blue*_13; blue+=(rowcopyOffset+xm)->blue*_21; blue+=(rowcopyOffset+xp)->blue*_23; blue+=(rowcopyOffset+yp+xm)->blue*_31; blue+=(rowcopyOffset+yp)->blue*_32; blue+=(rowcopyOffset+yp+xp)->blue*_33; blue = blue/scale; row->red=(unsigned char)min(255,max(0,red)); row->green=(unsigned char)min(255,max(0,green)); row->blue=(unsigned char)min(255,max(0,blue)); row++; rowcopyOffset++; } } delete[]rowcopy; return true;}To blur you use Filter33(bitmap_object_id,0,1,0,1,1,1,0,1,0,5)

To blur more use Filter33(bitmap_object_id,1,1,1,1,1,1,1,1,1,9)

To sharpen use Filter33(bitmap_object_id,0,-1,0,-1,5,-1,0,-1,0,1)

To sharpen more use Filter33(bitmap_object,-1,-1,-1,-1,9,-1,-1,-1,-1,1)

To detect edges use Filter33(bitmap_object,0,-1,0,-1,4,-1,0,-1,0,1)

To emboss use Filter33(bitmap_object,-2,-1,0,-1,1,1,0,1,2,1)

As you can see it's a very handy filter to have.

Here's a little something I'm playing around with:
 
Last edited by a moderator:
Joined
May 21, 2012
Messages
83
Reaction score
4
First Language
English
Primarily Uses
That looks pretty sweet. I'll post my bitmap effect code when I get home from school (I've got a radial blur algorithm that's pretty awesome). And I like the use of memcopy. I totally didn't know that function existed. And now that you've done that filter, I'll try to mod it to make it work with kernels of any size.

Edit - Here's my edit of your convolution kernel code to use kernels of any size.

#include <stdio.h>#include <stdlib.h>#include <string.h>#include <windows.h>#include <math.h> #define RGSSApi extern "C" __declspec(dllexport) typedef struct {unsigned char red;unsigned char green;unsigned char blue;unsigned char alpha;} RGSSRGBA; typedef struct{    DWORD unk1;    DWORD unk2;    BITMAPINFOHEADER *infoheader;    RGSSRGBA *firstRow;    RGSSRGBA *lastRow;} RGSSBMINFO; typedef struct{    DWORD unk1;    DWORD unk2;    RGSSBMINFO *bminfo;} BITMAPSTRUCT; typedef struct{    DWORD flags;    DWORD klass;    void (*dmark) (void*);    void (*dfree) (void*);    BITMAPSTRUCT *bm;} RGSSBITMAP; RGSSApi bool Filter33(long object, int kWidth, int kHeight, int* kernel, int scale){#pragma warning (disable:4312)    RGSSBMINFO *bitmap = ((RGSSBITMAP*)(object<<1))->bm->bminfo;#pragma warning (default:4312)     long width, height;    RGSSRGBA *row;RGSSRGBA *rowcopy;    long x, y;    float red,green,blue; int xm,xp,ym,yp; kWidth += kWidth % 2 - 1;kHeight += kHeight % 2 - 1;     if(!bitmap) return false;    width = bitmap->infoheader->biWidth;    height = bitmap->infoheader->biHeight; rowcopy=new RGSSRGBA[width*height];    row = bitmap->lastRow; RGSSRGBA *rowcopyOffset=rowcopy;memcpy(rowcopy,row,width*height*4); if(scale==0)scale=1;     for ( y = 0; y < height; y++) {            for ( x = 0; x < width; x++) {red = 0;green = 0;blue = 0;xm = -min((kWidth - 1) / 2, x);ym = -min((kHeight - 1) / 2, y);xp = min((kWidth - 1) / 2, width - x - 1);yp = min((kHeight - 1) / 2, height - y - 1);for (int i = 0;i < kWidth;i++) {for (int e = 0;e < kHeight;e++) {red += (rowcopyOffset + min(xp, max(xm, i - kWidth / 2)) + width * min(yp, max(ym, e - kHeight / 2))) -> red * kernel[i + e * kWidth];green += (rowcopyOffset + min(xp, max(xm, i - kWidth / 2)) + width * min(yp, max(ym, e - kHeight / 2))) -> green * kernel[i + e * kWidth];blue += (rowcopyOffset + min(xp, max(xm, i - kWidth / 2)) + width * min(yp, max(ym, e - kHeight / 2))) -> blue * kernel[i + e * kWidth];}}red /= scale;green /= scale;blue /= scale; row->red=(unsigned char)min(255,max(0,red));row->green=(unsigned char)min(255,max(0,green));row->blue=(unsigned char)min(255,max(0,blue));            row++;rowcopyOffset++;        }    } delete[]rowcopy;     return true;}
And here's my existing bitmap functions code, including a radial blur algorithm.

Code:
#include <cstdlib>#include <ctime>#include <ctype.h>#include <math.h>#include <stddef.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <windows.h>#include <time.h>#define M_PI 3.1415926535 double round(double d){  return floor(d + 0.5);} BOOL APIENTRY DllMain( HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved) {    switch (ul_reason_for_call) {        case DLL_PROCESS_ATTACH:        case DLL_THREAD_ATTACH:        case DLL_THREAD_DETACH:        case DLL_PROCESS_DETACH:        break;    }    return true;} typedef struct {    DWORD flags;    DWORD klass;    void (*dmark) (void*);    void (*dfree) (void*);    double *data; //red is index 1, green is index 2, blue 3, alpha 0} RGSSCOLOR; typedef struct{    DWORD unk1;    DWORD unk2;    BITMAPINFOHEADER *infoheader;    RGSSCOLOR *firstRow;    RGBQUAD *lastRow;} RGSSBMINFO; typedef struct{    DWORD unk1;    DWORD unk2;    RGSSBMINFO *bminfo;} BITMAPSTRUCT; typedef struct{    DWORD flags;    DWORD klass;    void (*dmark) (void*);    void (*dfree) (void*);    BITMAPSTRUCT *bm;} RGSSBITMAP; #define ASSERT(x) if(!x){DebugOut("Failed: %s: %d", #x, __LINE__);} extern "C" _declspec (dllexport) BOOL clear_rect(long object, int x, int y, int w, int h){    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;    DWORD rowsize;    DWORD width, height;    LPBYTE row;    int i, e;    //int red, green, blue;    if(!bitmap) return false;    width = bitmap -> infoheader -> biWidth;    height = bitmap -> infoheader -> biHeight;if(x>(int)width) x = width;if(y>(int)height) y = height;if(x<0) x = 0;if(y<0) y = 0;if(w<0) return false;if(h<0) return false;if(x+w>(int)width) w = width - x;if(y+h>(int)height) h = height - y;    rowsize = width * 4;    row = (LPBYTE) (bitmap -> firstRow);row -= rowsize * y;    for ( i = y; i < y + h; i++) {        LPBYTE thisrow = row;thisrow += 4 * x;        for ( e = x; e < x + w; e++) {            //red = thisrow[2];            //green = thisrow[1];            //blue = thisrow[0];thisrow[0] = 0;thisrow[1] = 0;thisrow[2] = 0;thisrow[3] = 0;            thisrow += 4;        }        row -= rowsize;    }    return true;} extern "C" _declspec (dllexport) BOOL fill_rect(long object, int x, int y, int w, int h, int r, int g, int b, int a){    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;    DWORD rowsize;    DWORD width, height;    LPBYTE row;    int i, e;    //int red, green, blue;    if(!bitmap) return false;    width = bitmap -> infoheader -> biWidth;    height = bitmap -> infoheader -> biHeight;if(x>(int)width) return false;if(y>(int)height) return false;if(x<0) {w += x;x = 0;}if(y<0) {h += y;y = 0;}if(w<0) return false;if(h<0) return false;if(x+w>(int)width) w = width - x;if(y+h>(int)height) h = height - y;    rowsize = width * 4;    row = (LPBYTE) (bitmap -> firstRow);row -= rowsize * y;    for ( i = y; i < y + h; i++) {        LPBYTE thisrow = row;thisrow += 4 * x;        for ( e = x; e < x + w; e++) {            thisrow[0] = b;thisrow[1] = g;thisrow[2] = r;thisrow[3] = a;            thisrow += 4;        }        row -= rowsize;    }    return true;} BOOL fill_rect2(int width, int height, LPBYTE row, int x, int y, int w, int h, int r, int g, int b, int a){    int rowsize;    int i, e;    //int red, green, blue;if(x>width) return false;if(y>height) return false;if(x<0) {w += x;x = 0;}if(y<0) {h += y;y = 0;}if(w<0) return false;if(h<0) return false;if(x+w>width) w = width - x;if(y+h>height) h = height - y;    rowsize = width * 4;//row -= rowsize * y;    for ( i = y; i < y + h; i++) {        LPBYTE thisrow = row;//thisrow += 4 * x;        for ( e = x; e < x + w; e++) {            thisrow[0] = b;thisrow[1] = g;thisrow[2] = r;thisrow[3] = a;            thisrow += 4;        }        row -= rowsize;    }    return true;} extern "C" _declspec (dllexport) BOOL blt(long object, long source, int x, int y, int srcx, int srcy, int w, int h, int opacity){RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;RGSSBMINFO *src = ((RGSSBITMAP*) (source<<1)) -> bm -> bminfo;    DWORD rowsize, srcrowsize;    DWORD width, height, srcwidth, srcheight;    LPBYTE row, srcrow;    int i, e, sa;int m2 = 255 * 255;    if(!bitmap) return false;if(opacity == 0) return false;    width = bitmap -> infoheader -> biWidth;    height = bitmap -> infoheader -> biHeight;    srcwidth = src -> infoheader -> biWidth;    srcheight = src -> infoheader -> biHeight;if(srcx>(int)srcwidth) srcx = srcwidth;if(srcy>(int)srcheight) srcy = srcheight;if(srcx<0) srcx = 0;if(srcy<0) srcy = 0;if(srcwidth<0) return false;if(srcheight<0) return false;if(srcx+w>(int)srcwidth) w = srcwidth - srcx;if(srcy+h>(int)srcheight) h = srcheight - srcy;if(x>(int)width) x = width;if(y>(int)height) y = height;if(x<0) x = 0;if(y<0) y = 0;if(w<0) return false;if(h<0) return false;if(x+w>(int)width) w = width - x;if(y+h>(int)height) h = height - y;    rowsize = width * 4;    srcrowsize = srcwidth * 4;    row = (LPBYTE) (bitmap -> firstRow);srcrow = (LPBYTE) (src -> firstRow);row -= rowsize * y;srcrow -= srcrowsize * srcy;    for ( i = y; i < y + h; i++) {        LPBYTE thisrow = row;LPBYTE thissrcrow = srcrow;thisrow += 4 * x;thissrcrow += 4 * srcx;        for ( e = x; e < x + w; e++) {sa = thissrcrow[3] * opacity;if (sa == m2) {thisrow[0] = thissrcrow[0];thisrow[1] = thissrcrow[1];thisrow[2] = thissrcrow[2];thisrow[3] = 255;} else if (thisrow[3] == 0) {thisrow[0] = thissrcrow[0];thisrow[1] = thissrcrow[1];thisrow[2] = thissrcrow[2];thisrow[3] = sa / 255;} else if (sa != 0) {sa /= 255;if (sa == 0) continue;thisrow[0] = thissrcrow[0] * sa / 255 + thisrow[0] * (255 - sa) / 255;thisrow[1] = thissrcrow[1] * sa / 255 + thisrow[1] * (255 - sa) / 255;thisrow[2] = thissrcrow[2] * sa / 255 + thisrow[2] * (255 - sa) / 255;thisrow[3] = min(thisrow[3] + sa * sa / 255, 255);}            thisrow += 4;thissrcrow += 4;        }        row -= rowsize;srcrow -= srcrowsize;    }    return true;} extern "C" _declspec (dllexport) BOOL simple_blt(long object, long source, int x, int y, int srcx, int srcy, int w, int h) {RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;RGSSBMINFO *src = ((RGSSBITMAP*) (source<<1)) -> bm -> bminfo;    DWORD rowsize, srcrowsize;    DWORD width, height, srcwidth, srcheight;    LPBYTE row, srcrow;    int i, e;    if(!bitmap) return false;    width = bitmap -> infoheader -> biWidth;    height = bitmap -> infoheader -> biHeight;    srcwidth = src -> infoheader -> biWidth;    srcheight = src -> infoheader -> biHeight;if(srcx>(int)srcwidth) srcx = srcwidth;if(srcy>(int)srcheight) srcy = srcheight;if(srcx<0) srcx = 0;if(srcy<0) srcy = 0;if(srcwidth<0) return false;if(srcheight<0) return false;if(srcx+w>(int)srcwidth) w = srcwidth - srcx;if(srcy+h>(int)srcheight) h = srcheight - srcy;if(x>(int)width) x = width;if(y>(int)height) y = height;if(x<0) x = 0;if(y<0) y = 0;if(w<0) return false;if(h<0) return false;if(x+w>(int)width) w = width - x;if(y+h>(int)height) h = height - y;    rowsize = width * 4;    srcrowsize = srcwidth * 4;    row = (LPBYTE) (bitmap -> firstRow);srcrow = (LPBYTE) (src -> firstRow);row -= rowsize * y;srcrow -= srcrowsize * srcy;    for ( i = y; i < y + h; i++) {        LPBYTE thisrow = row;LPBYTE thissrcrow = srcrow;thisrow += 4 * x;thissrcrow += 4 * srcx;        for ( e = x; e < x + w; e++) {thisrow[0] = thissrcrow[0];thisrow[1] = thissrcrow[1];thisrow[2] = thissrcrow[2];thisrow[3] = thissrcrow[3];            thisrow += 4;thissrcrow += 4;        }        row -= rowsize;srcrow -= srcrowsize;    }    return true;} extern "C" _declspec (dllexport) BOOL blend_blt(long object, long source, int x, int y, int srcx, int srcy, int w, int h, int blend_type, int opacity){//if (blend_type == 0) return blt(object, source, x, y, srcx, srcy, w, h, opacity);RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;RGSSBMINFO *src = ((RGSSBITMAP*) (source<<1)) -> bm -> bminfo;    DWORD rowsize, srcrowsize;    DWORD width, height, srcwidth, srcheight;    LPBYTE row, srcrow;    int i, e, sa;int m2 = 255 * 255;    if(!bitmap) return false;if(opacity == 0 && blend_type != 12) return false;    width = bitmap -> infoheader -> biWidth;    height = bitmap -> infoheader -> biHeight;    srcwidth = src -> infoheader -> biWidth;    srcheight = src -> infoheader -> biHeight;if(srcx>(int)srcwidth) srcx = srcwidth;if(srcy>(int)srcheight) srcy = srcheight;if(srcx<0) srcx = 0;if(srcy<0) srcy = 0;if(srcwidth<0) return false;if(srcheight<0) return false;if(srcx+w>(int)srcwidth) w = srcwidth - srcx;if(srcy+h>(int)srcheight) h = srcheight - srcy;if(x>(int)width) x = width;if(y>(int)height) y = height;if(x<0) x = 0;if(y<0) y = 0;if(w<0) return false;if(h<0) return false;if(x+w>(int)width) w = width - x;if(y+h>(int)height) h = height - y;    rowsize = width * 4;    srcrowsize = srcwidth * 4;    row = (LPBYTE) (bitmap -> firstRow);srcrow = (LPBYTE) (src -> firstRow);row -= rowsize * y;srcrow -= srcrowsize * srcy;if (blend_type == 12) srand(time(NULL));    for ( i = y; i < y + h; i++) {        LPBYTE thisrow = row;LPBYTE thissrcrow = srcrow;thisrow += 4 * x;thissrcrow += 4 * srcx;        for ( e = x; e < x + w; e++) {int tmp;sa = thissrcrow[3] * opacity;switch (blend_type) {case 0:if (sa == m2) {thisrow[0] = thissrcrow[0];thisrow[1] = thissrcrow[1];thisrow[2] = thissrcrow[2];thisrow[3] = 255;} else if (thisrow[3] == 0) {thisrow[0] = thissrcrow[0];thisrow[1] = thissrcrow[1];thisrow[2] = thissrcrow[2];thisrow[3] = sa / 255;} else if (sa != 0) {sa /= 255;if (sa == 0) continue;thisrow[0] = ((int)thissrcrow[0] * sa + thisrow[0] * (255 - sa)) / 255;thisrow[1] = ((int)thissrcrow[1] * sa + thisrow[1] * (255 - sa)) / 255;thisrow[2] = ((int)thissrcrow[2] * sa + thisrow[2] * (255 - sa)) / 255;tmp = thisrow[3] + sa * sa / 255;if (tmp <= 255)thisrow[3] = tmp;elsethisrow[3] = 255;}break;case 1:if (sa == m2) {if (thisrow[0] + thissrcrow[0] <= 255)thisrow[0] += thissrcrow[0];elsethisrow[0] = 255;if (thisrow[1] + thissrcrow[1] <= 255)thisrow[1] += thissrcrow[1];elsethisrow[1] = 255;if (thisrow[2] + thissrcrow[2] <= 255)thisrow[2] += thissrcrow[2];elsethisrow[2] = 255;} else if (thisrow[3] == 0) {thisrow[0] = thissrcrow[0];thisrow[1] = thissrcrow[1];thisrow[2] = thissrcrow[2];thisrow[3] = sa / 255;} else if (sa != 0) {sa /= 255;if (sa == 0) continue;tmp = thisrow[0] + thissrcrow[0] * sa / 255;if (tmp <= 255)thisrow[0] = tmp;elsethisrow[0] = 255;tmp = thisrow[1] + thissrcrow[1] * sa / 255;if (tmp <= 255)thisrow[1] = tmp;elsethisrow[1] = 255;tmp = thisrow[2] + thissrcrow[2] * sa / 255;if (tmp <= 255)thisrow[2] = tmp;elsethisrow[2] = 255;tmp = thisrow[3] + sa * sa / 255;if (tmp <= 255)thisrow[3] = tmp;elsethisrow[3] = 255;//thisrow[0] = min(thisrow[0] + thissrcrow[0] * sa / 255, 255);//thisrow[1] = min(thisrow[1] + thissrcrow[1] * sa / 255, 255);//thisrow[2] = min(thisrow[2] + thissrcrow[2] * sa / 255, 255);//thisrow[3] = min(thisrow[3] + sa * sa / 255, 255);}break;case 2:if (sa == m2) {if (thisrow[0] - thissrcrow[0] >= 0)thisrow[0] -= thissrcrow[0];elsethisrow[0] = 0;if (thisrow[1] - thissrcrow[1] >= 0)thisrow[1] -= thissrcrow[1];elsethisrow[1] = 0;if (thisrow[2] - thissrcrow[2] >= 0)thisrow[2] -= thissrcrow[2];elsethisrow[2] = 0;} else if (thisrow[3] == 0) {thisrow[0] = 0;thisrow[1] = 0;thisrow[2] = 0;thisrow[3] = sa / 255;} else if (sa != 0) {sa /= 255;if (sa == 0) continue;tmp = thisrow[0] - thissrcrow[0] * sa / 255;if (tmp >= 0)thisrow[0] = tmp;elsethisrow[0] = 0;tmp = thisrow[1] - thissrcrow[1] * sa / 255;if (tmp >= 0)thisrow[1] = tmp;elsethisrow[1] = 0;tmp = thisrow[2] - thissrcrow[2] * sa / 255;if (tmp >= 0)thisrow[2] = tmp;elsethisrow[2] = 0;tmp = thisrow[3] + sa * sa / 255;if (tmp <= 255)thisrow[3] = tmp;elsethisrow[3] = 255;//thisrow[0] = min(thisrow[0] + thissrcrow[0] * sa / 255, 255);//thisrow[1] = min(thisrow[1] + thissrcrow[1] * sa / 255, 255);//thisrow[2] = min(thisrow[2] + thissrcrow[2] * sa / 255, 255);//thisrow[3] = min(thisrow[3] + sa * sa / 255, 255);}break;case 3:if (sa == m2) {thisrow[0] = thisrow[0] * thissrcrow[0] / 255;thisrow[1] = thisrow[1] * thissrcrow[1] / 255;thisrow[2] = thisrow[2] * thissrcrow[2] / 255;thisrow[3] = 255;} else if (sa != 0) {sa /= 255;if (sa == 0) continue;thisrow[0] = (thisrow[0] * (255 - sa) + thisrow[0] * thissrcrow[0] * sa / 255) / 255;thisrow[1] = (thisrow[1] * (255 - sa) + thisrow[1] * thissrcrow[1] * sa / 255) / 255;thisrow[2] = (thisrow[2] * (255 - sa) + thisrow[2] * thissrcrow[2] * sa / 255) / 255;tmp = thisrow[3] + sa * sa / 255;if (tmp <= 255)thisrow[3] = tmp;elsethisrow[3] = 255;}break;case 4:if (sa == m2) {thisrow[0] = 255 - (255 - thisrow[0]) * (255 - thissrcrow[0]) / 255;thisrow[1] = 255 - (255 - thisrow[1]) * (255 - thissrcrow[1]) / 255;thisrow[2] = 255 - (255 - thisrow[2]) * (255 - thissrcrow[2]) / 255;thisrow[3] = 255;} else if (sa != 0) {sa /= 255;if (sa == 0) continue;thisrow[0] = (thisrow[0] * (255 - sa) + sa * (255 - (255 - thisrow[0]) * (255 - thissrcrow[0]) / 255)) / 255;thisrow[1] = (thisrow[1] * (255 - sa) + sa * (255 - (255 - thisrow[1]) * (255 - thissrcrow[1]) / 255)) / 255;thisrow[2] = (thisrow[2] * (255 - sa) + sa * (255 - (255 - thisrow[2]) * (255 - thissrcrow[2]) / 255)) / 255;tmp = thisrow[3] + sa * sa / 255;if (tmp <= 255)thisrow[3] = tmp;elsethisrow[3] = 255;}break;case 5:if (sa == m2) {if (thisrow[0] > 127)thisrow[0] = 255 - (255 - thisrow[0]) * (255 - thissrcrow[0]) / 255;elsethisrow[0] = thisrow[0] * thissrcrow[0] / 255;if (thisrow[1] > 127)thisrow[1] = 255 - (255 - thisrow[1]) * (255 - thissrcrow[1]) / 255;elsethisrow[1] = thisrow[1] * thissrcrow[1] / 255;if (thisrow[2] > 127)thisrow[2] = 255 - (255 - thisrow[2]) * (255 - thissrcrow[2]) / 255;elsethisrow[2] = thisrow[2] * thissrcrow[2] / 255;thisrow[3] = 255;} else if (sa != 0) {sa /= 255;if (sa == 0) continue;if (thisrow[0] > 127)thisrow[0] = (thisrow[0] * (255 - sa) + sa * (255 - (255 - thisrow[0]) * (255 - thissrcrow[0]) / 255)) / 255;elsethisrow[0] = (thisrow[0] * (255 - sa) + thisrow[0] * thissrcrow[0] * sa / 255) / 255;if (thisrow[1] > 127)thisrow[1] = (thisrow[1] * (255 - sa) + sa * (255 - (255 - thisrow[1]) * (255 - thissrcrow[1]) / 255)) / 255;elsethisrow[1] = (thisrow[1] * (255 - sa) + thisrow[1] * thissrcrow[1] * sa / 255) / 255;if (thisrow[2] > 127)thisrow[2] = (thisrow[2] * (255 - sa) + sa * (255 - (255 - thisrow[2]) * (255 - thissrcrow[2]) / 255)) / 255;elsethisrow[2] = (thisrow[2] * (255 - sa) + thisrow[2] * thissrcrow[2] * sa / 255) / 255;tmp = thisrow[3] + sa * sa / 255;if (tmp <= 255)thisrow[3] = tmp;elsethisrow[3] = 255;}break;case 6:if (sa == m2) {thisrow[0] = (-thisrow[0] * (2 * (thisrow[0] - 255) * thissrcrow[0] - 255 * thisrow[0])) / (255 * 255);thisrow[1] = (-thisrow[1] * (2 * (thisrow[1] - 255) * thissrcrow[1] - 255 * thisrow[1])) / (255 * 255);thisrow[2] = (-thisrow[2] * (2 * (thisrow[2] - 255) * thissrcrow[2] - 255 * thisrow[2])) / (255 * 255);thisrow[3] = 255;} else if (sa != 0) {sa /= 255;if (sa == 0) continue;thisrow[0] = (thisrow[0] * (255 - sa) + sa * (-thisrow[0] * (2 * (thisrow[0] - 255) * thissrcrow[0] - 255 * thisrow[0])) / (255 * 255)) / 255;thisrow[1] = (thisrow[1] * (255 - sa) + sa * (-thisrow[1] * (2 * (thisrow[1] - 255) * thissrcrow[1] - 255 * thisrow[1])) / (255 * 255)) / 255;thisrow[2] = (thisrow[2] * (255 - sa) + sa * (-thisrow[2] * (2 * (thisrow[2] - 255) * thissrcrow[2] - 255 * thisrow[2])) / (255 * 255)) / 255;tmp = thisrow[3] + sa * sa / 255;if (tmp <= 255)thisrow[3] = tmp;elsethisrow[3] = 255;}break;case 7:if (sa == m2) {if (255 - thissrcrow[0] > thisrow[0])thisrow[0] = thisrow[0] * 255 / (255 - thissrcrow[0]);elsethisrow[0] = 255;if (255 - thissrcrow[1] > thisrow[1])thisrow[1] = thisrow[1] * 255 / (255 - thissrcrow[1]);elsethisrow[1] = 255;if (255 - thissrcrow[2] > thisrow[2])thisrow[2] = thisrow[2] * 255 / (255 - thissrcrow[2]);elsethisrow[2] = 255;thisrow[3] = 255;} else if (sa != 0) {sa /= 255;if (sa == 0) continue;if (thissrcrow[0] != 255) {tmp = (thisrow[0] * (255 - sa) + sa * thisrow[0] * 255 / (255 - thissrcrow[0])) / 255;if (tmp <= 255 && tmp >= 0)thisrow[0] = tmp;else if (tmp < 0)thisrow[0] = 0;elsethisrow[0] = 255;}if (thissrcrow[1] != 255) {tmp = (thisrow[1] * (255 - sa) + sa * thisrow[1] * 255 / (255 - thissrcrow[1])) / 255;if (tmp <= 255 && tmp >= 0)thisrow[1] = tmp;else if (tmp < 0)thisrow[1] = 0;elsethisrow[1] = 255;}if (thissrcrow[2] == 255) {tmp = (thisrow[2] * (255 - sa) + sa * thisrow[2] * 255 / (255 - thissrcrow[2])) / 255;if (tmp <= 255 && tmp >= 0)thisrow[2] = tmp;else if (tmp < 0)thisrow[2] = 0;elsethisrow[2] = 255;}tmp = thisrow[3] + sa * sa / 255;if (tmp <= 255)thisrow[3] = tmp;elsethisrow[3] = 255;}break;case 8:if (sa == m2) {if (thissrcrow[0] > 255 - thisrow[0])thisrow[0] = 255 - (255 - thisrow[0]) * 255 / (thissrcrow[0]);elsethisrow[0] = 0;if (thissrcrow[1] > 255 - thisrow[1])thisrow[1] = 255 - (255 - thisrow[1]) * 255 / (thissrcrow[1]);elsethisrow[1] = 0;if (thissrcrow[2] > 255 - thisrow[2])thisrow[2] = 255 - (255 - thisrow[2]) * 255 / (thissrcrow[2]);elsethisrow[2] = 0;thisrow[3] = 255;} else if (sa != 0) {sa /= 255;if (sa == 0) continue;if (thissrcrow[0] == 0) {thisrow[0] = 255 - thisrow[0];} else {tmp = (thisrow[0] * (255 - sa) + sa * (255 - (255 - thisrow[0]) * 255 / thissrcrow[0])) / 255;if (tmp <= 255 && tmp >= 0)thisrow[0] = tmp;else if (tmp < 0)thisrow[0] = 0;elsethisrow[0] = 255;}if (thissrcrow[1] == 0) {thisrow[1] = 255 - thisrow[1];} else {tmp = (thisrow[1] * (255 - sa) + sa * (255 - (255 - thisrow[1]) * 255 / thissrcrow[1])) / 255;if (tmp <= 255 && tmp >= 0)thisrow[1] = tmp;else if (tmp < 0)thisrow[1] = 0;elsethisrow[1] = 255;}if (thissrcrow[2] == 0) {thisrow[2] = 255 - thisrow[2];} else {tmp = (thisrow[2] * (255 - sa) + sa * (255 - (255 - thisrow[2]) * 255 / thissrcrow[2])) / 255;if (tmp <= 255 && tmp >= 0)thisrow[2] = tmp;else if (tmp < 0)thisrow[2] = 0;elsethisrow[2] = 255;}tmp = thisrow[3] + sa * sa / 255;if (tmp <= 255)thisrow[3] = tmp;elsethisrow[3] = 255;}break;case 9:if (sa == m2) {tmp = thisrow[0] + thissrcrow[0] - 255;if (tmp >= 0)thisrow[0] = tmp;elsethisrow[0] = 0;tmp = thisrow[1] + thissrcrow[1] - 255;if (tmp >= 0)thisrow[1] = tmp;elsethisrow[1] = 0;tmp = thisrow[2] + thissrcrow[2] - 255;if (tmp >= 0)thisrow[2] = tmp;elsethisrow[2] = 0;thisrow[3] = 255;} else if (thisrow[3] == 0) {thisrow[0] = 0;thisrow[1] = 0;thisrow[2] = 0;thisrow[3] = sa / 255;} else if (sa != 0) {sa /= 255;if (sa == 0) continue;tmp = (thisrow[0] * (255 - sa) + sa * (thisrow[0] + thissrcrow[0] - 255)) / 255;if (tmp >= 0)thisrow[0] = tmp;elsethisrow[0] = 0;tmp = (thisrow[1] * (255 - sa) + sa * (thisrow[1] + thissrcrow[1] - 255)) / 255;if (tmp >= 0)thisrow[1] = tmp;elsethisrow[1] = 0;tmp = (thisrow[2] * (255 - sa) + sa * (thisrow[2] + thissrcrow[2] - 255)) / 255;if (tmp >= 0)thisrow[2] = tmp;elsethisrow[2] = 0;tmp = thisrow[3] + sa * sa / 255;if (tmp <= 255)thisrow[3] = tmp;elsethisrow[3] = 255;}break;case 10:if (sa == m2) {if (thisrow[0] > thissrcrow[0])thisrow[0] = thissrcrow[0] * 255 / thisrow[0];elsethisrow[0] = 255;if (thisrow[1] > thissrcrow[1])thisrow[1] = thissrcrow[1] * 255 / thisrow[1];elsethisrow[1] = 255;if (thisrow[2] > thissrcrow[2])thisrow[2] = thissrcrow[2] * 255 / thisrow[2];elsethisrow[2] = 255;thisrow[3] = 255;} else if (sa != 0) {sa /= 255;if (sa == 0) continue;if (thisrow[0] == 0) {thisrow[0] = thissrcrow[0];} else {tmp = (thisrow[0] * (255 - sa) + sa * thissrcrow[0] * 255 / thisrow[0]) / 255;if (tmp <= 255 && tmp >= 0)thisrow[0] = tmp;else if (tmp < 0)thisrow[0] = 0;elsethisrow[0] = 255;}if (thisrow[1] == 0) {thisrow[1] = thissrcrow[1];} else {tmp = (thisrow[1] * (255 - sa) + sa * thissrcrow[1] * 255 / thisrow[1]) / 255;if (tmp <= 255 && tmp >= 0)thisrow[1] = tmp;else if (tmp < 0)thisrow[1] = 0;elsethisrow[1] = 255;}if (thisrow[2] == 0) {thisrow[2] = thissrcrow[2];} else {tmp = (thisrow[2] * (255 - sa) + sa * thissrcrow[2] * 255 / thisrow[2]) / 255;if (tmp <= 255 && tmp >= 0)thisrow[2] = tmp;else if (tmp < 0)thisrow[2] = 0;elsethisrow[2] = 255;tmp = thisrow[3] + sa * sa / 255;if (tmp <= 255)thisrow[3] = tmp;elsethisrow[3] = 255;}}break;case 11:sa /= 255;if (sa == 0) continue;thisrow[0] = fabs((float)(thisrow[0] - thissrcrow[0]));thisrow[1] = fabs((float)(thisrow[1] - thissrcrow[1]));thisrow[2] = fabs((float)(thisrow[2] - thissrcrow[2]));tmp = thisrow[3] + sa * sa / 255;if (tmp <= 255)thisrow[3] = tmp;elsethisrow[3] = 255;break;case 12:if (rand() % 258 < opacity + 1) {thisrow[0] = thissrcrow[0];thisrow[1] = thissrcrow[1];thisrow[2] = thissrcrow[2];thisrow[3] = thissrcrow[3];}break;}            thisrow += 4;thissrcrow += 4;        }        row -= rowsize;srcrow -= srcrowsize;    }    return true;} extern "C" _declspec (dllexport) BOOL transfer_blt(long object, long source, int x, int y, int srcx, int srcy, int w, int h, int transfer_mode, int opacity){RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;RGSSBMINFO *src = ((RGSSBITMAP*) (source<<1)) -> bm -> bminfo;    DWORD rowsize, srcrowsize;    DWORD width, height, srcwidth, srcheight;    LPBYTE row, srcrow;    int i, e, sa;int m2 = 255 * 255;    if(!bitmap) return false;if(opacity == 0) return false;    width = bitmap -> infoheader -> biWidth;    height = bitmap -> infoheader -> biHeight;    srcwidth = src -> infoheader -> biWidth;    srcheight = src -> infoheader -> biHeight;if(srcx>(int)srcwidth) srcx = srcwidth;if(srcy>(int)srcheight) srcy = srcheight;if(srcx<0) srcx = 0;if(srcy<0) srcy = 0;if(srcwidth<0) return false;if(srcheight<0) return false;if(srcx+w>(int)srcwidth) w = srcwidth - srcx;if(srcy+h>(int)srcheight) h = srcheight - srcy;if(x>(int)width) x = width;if(y>(int)height) y = height;if(x<0) x = 0;if(y<0) y = 0;if(w<0) return false;if(h<0) return false;if(x+w>(int)width) w = width - x;if(y+h>(int)height) h = height - y;    rowsize = width * 4;    srcrowsize = srcwidth * 4;    row = (LPBYTE) (bitmap -> firstRow);srcrow = (LPBYTE) (src -> firstRow);row -= rowsize * y;srcrow -= srcrowsize * srcy;    for ( i = y; i < y + h; i++) {        LPBYTE thisrow = row;LPBYTE thissrcrow = srcrow;thisrow += 4 * x;thissrcrow += 4 * srcx;        for ( e = x; e < x + w; e++) {sa = thissrcrow[3] * opacity;switch (transfer_mode) {case 0:if (sa == m2) {thisrow[0] = thissrcrow[0];thisrow[1] = thissrcrow[1];thisrow[2] = thissrcrow[2];thisrow[3] = 255;} else if (thisrow[3] == 0) {thisrow[0] = thissrcrow[0];thisrow[1] = thissrcrow[1];thisrow[2] = thissrcrow[2];thisrow[3] = sa / 255;} else if (sa != 0) {sa /= 255;if (sa == 0) continue;thisrow[0] = thissrcrow[0] * sa / 255 + thisrow[0] * (255 - sa) / 255;thisrow[1] = thissrcrow[1] * sa / 255 + thisrow[1] * (255 - sa) / 255;thisrow[2] = thissrcrow[2] * sa / 255 + thisrow[2] * (255 - sa) / 255;thisrow[3] = min(thisrow[3] + sa * sa / 255, 255);}break;case 1:thisrow[0] = thissrcrow[0];thisrow[1] = thissrcrow[1];thisrow[2] = thissrcrow[2];thisrow[3] = thissrcrow[3] * opacity / 255;break;case 2:if (thisrow[3] == 0) {} else if (sa == m2) {thisrow[0] = thissrcrow[0];thisrow[1] = thissrcrow[1];thisrow[2] = thissrcrow[2];} else if (sa != 0) {sa /= 255;if (sa == 0) continue;thisrow[0] = (thissrcrow[0] * sa + thisrow[0] * (255 - sa)) / 255;thisrow[1] = (thissrcrow[1] * sa + thisrow[1] * (255 - sa)) / 255;thisrow[2] = (thissrcrow[2] * sa + thisrow[2] * (255 - sa)) / 255;}break;case 3:if (thisrow[3] == 255) {} else if (sa == m2 ) {thisrow[0] = (thissrcrow[0] * (255 - thisrow[3]) + thisrow[0] * thisrow[3]) / 255;thisrow[1] = (thissrcrow[1] * (255 - thisrow[3]) + thisrow[1] * thisrow[3]) / 255;thisrow[2] = (thissrcrow[2] * (255 - thisrow[3]) + thisrow[2] * thisrow[3]) / 255;thisrow[3] = 255;} else if (sa != 0) {sa /= 255;thisrow[0] = (thissrcrow[0] * (255 - thisrow[3]) * sa + thisrow[0] * thisrow[3] * (510 - sa)) / m2;thisrow[1] = (thissrcrow[1] * (255 - thisrow[3]) * sa + thisrow[1] * thisrow[3] * (510 - sa)) / m2;thisrow[2] = (thissrcrow[2] * (255 - thisrow[3]) * sa + thisrow[2] * thisrow[3] * (510 - sa)) / m2;thisrow[3] += (255 - thisrow[3]) * sa / 255;}break;}            thisrow += 4;thissrcrow += 4;        }        row -= rowsize;srcrow -= srcrowsize;    }    return true;} extern "C" _declspec (dllexport) bool transition_in(long object, long transition, int frames, int duration, int rdur) {RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;RGSSBMINFO *trans = ((RGSSBITMAP*) (transition<<1)) -> bm -> bminfo;int w, h, tw, th;DWORD rowsize, trsize;LPBYTE row, tr;int ofs;int i, e, ind;if(!bitmap) return false;w = bitmap -> infoheader -> biWidth;h = bitmap -> infoheader -> biHeight;tw = trans -> infoheader -> biWidth;th = trans -> infoheader -> biHeight;if (tw < w || th < h) return false;//rdur = duration / 2;ofs = (duration - rdur);rowsize = w * 4;trsize = tw * 4;row = (LPBYTE) bitmap -> firstRow;tr = (LPBYTE) trans -> firstRow;for ( i = 0; i < h; i++) {        LPBYTE thisrow = row;LPBYTE thissrcrow = tr;        for ( e = 0; e < w; e++) {            ind = thissrcrow[2];if (frames - ind * ofs / 255 > 0 && frames - ind * ofs / 255 <= rdur) {thisrow[3] = thisrow[3] * (frames - ind * ofs / 255) / rdur;} else if (frames - ind * ofs / 255 <= 0) {thisrow[3] = 0;}            thisrow += 4;thissrcrow += 4;        }        row -= rowsize;tr -= trsize;    }return true;} extern "C" _declspec (dllexport) bool transition_out(long object, long transition, int frames, int duration, int rdur) {RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;RGSSBMINFO *trans = ((RGSSBITMAP*) (transition<<1)) -> bm -> bminfo;int w, h, tw, th;DWORD rowsize, trsize;LPBYTE row, tr;int ofs;int i, e, ind;if(!bitmap) return false;w = bitmap -> infoheader -> biWidth;h = bitmap -> infoheader -> biHeight;tw = trans -> infoheader -> biWidth;th = trans -> infoheader -> biHeight;if (tw < w || th < h) return false;ofs = (duration - rdur);rowsize = w * 4;trsize = tw * 4;row = (LPBYTE) bitmap -> firstRow;tr = (LPBYTE) trans -> firstRow;for ( i = 0; i < h; i++) {        LPBYTE thisrow = row;LPBYTE thissrcrow = tr;        for ( e = 0; e < w; e++) {            ind = thissrcrow[2];if (frames - ind * ofs / 255 > 0 && frames - ind * ofs / 255 <= rdur) {thisrow[3] = thisrow[3] - thisrow[3] * (frames - ind * ofs / 255) / rdur;} else if (frames - ind * ofs / 255 > rdur) {thisrow[3] = 0;}            thisrow += 4;thissrcrow += 4;        }        row -= rowsize;tr -= trsize;    }return true;} extern "C" _declspec (dllexport) bool draw_map(int* data, int* priority, int* sizes, long tileset, long* autotiles, long layer, int ox, int oy, int pri) {RGSSBMINFO *bitmap = ((RGSSBITMAP*) (layer<<1)) -> bm -> bminfo;int width, height;int ind, i, e, a;int tileid, xoff, yoff, z;if(!bitmap) return false;width = bitmap -> infoheader -> biWidth;height = bitmap -> infoheader -> biHeight;ind = 0;for(i = 0; i < width / 32; i++) {for(e = 0; e < height / 32; e++) {for(a = 0; a < sizes[2]; a++) {//ind = (i * sizes[1] * sizes[0] + e * sizes[0] + a);tileid = (int)data[ind];z = (int)priority[ind];ind++;if(z!=pri) continue;if(tileid >= 384) {tileid -= 384;xoff = tileid % 8;yoff = floor(tileid / 8.0);blt(layer, tileset, i * 32, e * 32, xoff * 32, yoff * 32, 32, 32, 255);}}}}return true;} extern "C" _declspec (dllexport) bool split_bitmap(long object1, long object2, int change_y, int change_x){if(change_y == 0 && change_x == 0) return false;RGSSBMINFO *bitmap1 = ((RGSSBITMAP*) (object1<<1)) -> bm -> bminfo;RGSSBMINFO *bitmap2 = ((RGSSBITMAP*) (object2<<1)) -> bm -> bminfo;    DWORD width1, width2, height1, height2, size;int strtx, strty, xmod, ymod;int x;double ratio;if(!bitmap1 || !bitmap2) return false;width1 = bitmap1 -> infoheader -> biWidth;height1 = bitmap1 -> infoheader -> biHeight;width2 = bitmap2 -> infoheader -> biWidth;height2 = bitmap2 -> infoheader -> biHeight;if(width1 != width2 || height1 != height2) return false;size = min(width1, height1);xmod = (width1 - size) / 2;ymod = (height1 - size) / 2;xmod = (xmod == 0) ? -ymod / fabs((float)(change_y)) : xmod;ymod = (ymod == 0) ? -xmod / fabs((float)(change_x)) : ymod;x = 0;ratio = ((float) width1) / height1;if(fabs((float)(change_y * ratio)) >= fabs((float)(change_x)) && change_y > 0) {strtx = xmod + ((float) size) / 2 - ((float) change_x) / change_y * size / 2;strty = 0;while (strty < (int)height1) {blt(object2, object1, strtx, strty, strtx, strty, width1 - strtx, change_y, 255);clear_rect(object1, strtx, strty, width1 - strtx, change_y);strty += change_y;strtx += change_x;x++;}} else if(fabs((float)(change_y * ratio)) >= fabs((float)(change_x))) {strtx = xmod + ((float) size) / 2 - ((float) change_x) / (-change_y) * size / 2;strty = height1 + change_y;while (strty > 0) {blt(object2, object1, strtx, strty, strtx, strty, width1 - strtx, -change_y, 255);clear_rect(object1, strtx, strty, width1 - strtx, -change_y);strty += change_y;strtx += change_x;x++;}} else if(change_x > 0) {strtx = 0;strty = ymod + ((float) size) / 2 - ((float) change_y) / change_x * size / 2;while (strtx < (int)width1) {blt(object2, object1, strtx, strty, strtx, strty, change_x, height1 - strty, 255);clear_rect(object1, strtx, strty, change_x, height1 - strty);strty += change_y;strtx += change_x;x++;}} else {strtx = width1 + change_x;strty = ymod + ((float) size) / 2 - ((float) change_y) / (-change_x) * size / 2;while (strtx > 0) {blt(object2, object1, strtx, strty, strtx, strty, -change_x, height1 - strty, 255);clear_rect(object1, strtx, strty, -change_x, height1 - strty);strty += change_y;strtx += change_x;x++;}}    return true;} extern "C" _declspec (dllexport) BOOL tint(long object, int amount, int r, int g, int {    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;    DWORD rowsize;    DWORD width, height;    LPBYTE row;    int i, e;    //int red, green, blue;    if(!bitmap) return false;    width = bitmap -> infoheader -> biWidth;    height = bitmap -> infoheader -> biHeight;    rowsize = width * 4;    row = (LPBYTE) (bitmap -> firstRow);    for ( i = 0; i < (int)height; i++) {        LPBYTE thisrow = row;        for ( e = 0; e < (int)width; e++) {thisrow[0] = (((float) amount) * b + ((float) (100 - amount)) * thisrow[0]) / 100;thisrow[1] = (((float) amount) * g + ((float) (100 - amount)) * thisrow[1]) / 100;thisrow[2] = (((float) amount) * r + ((float) (100 - amount)) * thisrow[2]) / 100;            thisrow += 4;        }        row -= rowsize;    }    return true;} extern "C" _declspec (dllexport) BOOL colorize(long object, int amount, int r, int g, int {    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;    DWORD rowsize;    DWORD width, height;    LPBYTE row;    int i, e;int avg;    //int red, green, blue;    if(!bitmap) return false;    width = bitmap -> infoheader -> biWidth;    height = bitmap -> infoheader -> biHeight;    rowsize = width * 4;    row = (LPBYTE) (bitmap -> firstRow);    for ( i = 0; i < (int)height; i++) {        LPBYTE thisrow = row;        for ( e = 0; e < (int)width; e++) {            avg = (thisrow[0] + thisrow[1] + thisrow[2]) / 3;thisrow[0] = (((float) amount) * b + ((float) (100 - amount)) * avg) / 100;thisrow[1] = (((float) amount) * g + ((float) (100 - amount)) * avg) / 100;thisrow[2] = (((float) amount) * r + ((float) (100 - amount)) * avg) / 100;            thisrow += 4;        }        row -= rowsize;    }    return true;} extern "C" _declspec (dllexport) BOOL grayscale(long object, int amount){    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;    DWORD rowsize;    DWORD width, height;    LPBYTE row;    int i, e;int avg;    if(!bitmap) return false;if(amount == 0) return true;    width = bitmap -> infoheader -> biWidth;    height = bitmap -> infoheader -> biHeight;    rowsize = width * 4;    row = (LPBYTE) (bitmap -> firstRow);    for ( i = 0; i < (int)height; i++) {        LPBYTE thisrow = row;        for ( e = 0; e < (int)width; e++) {            avg = (thisrow[0] + thisrow[1] + thisrow[2]) / 3;if (amount < 100) {thisrow[0] = (((float) (100 - amount)) * thisrow[0] + ((float) amount) * avg) / 100;thisrow[1] = (((float) (100 - amount)) * thisrow[1] + ((float) amount) * avg) / 100;thisrow[2] = (((float) (100 - amount)) * thisrow[2] + ((float) amount) * avg) / 100;} else {thisrow[0] = avg;thisrow[1] = avg;thisrow[2] = avg;}            thisrow += 4;        }        row -= rowsize;    }    return true;} extern "C" _declspec (dllexport) BOOL ripple(long object, long source, int amplitude, int wavelength, int dir){//if(wavelength == 0) return false;    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;    DWORD width, height;    int i;int shift;    //int red, green, blue;    if(!bitmap) return false;    width = bitmap -> infoheader -> biWidth;    height = bitmap -> infoheader -> biHeight;shift = 0;clear_rect(object, 0, 0, width, height);if (dir == 0) {for ( i = 0; i < (int)height; i++) {shift = sin((float) i / amplitude) * wavelength;if (wavelength > 0) {blt(object, source, shift + wavelength, i, 0, i, width, 1, 255);} else {blt(object, source, shift - wavelength, i, 0, i, width, 1, 255);}}} else {for ( i = 0; i < (int)width; i++) {shift = sin((float) i / amplitude) * wavelength;if (wavelength > 0) {blt(object, source, i, shift + wavelength, i, 0, 1, height, 255);} else {blt(object, source, i, shift - wavelength, i, 0, 1, height, 255);}}}        return true;} extern _declspec (dllexport) int get_pixel(long object, int x, int y, int index) {    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;    DWORD rowsize;    DWORD width, height;    LPBYTE row;    if(!bitmap) return false;    width = bitmap -> infoheader -> biWidth;    height = bitmap -> infoheader -> biHeight;if(y > (int)height - 1 || x > (int)width - 1 || y < 0 || x < 0) return false;    rowsize = width * 4;    row = (LPBYTE) (bitmap -> firstRow);row -= rowsize * y;row += x * 4;return row[index];} extern "C" _declspec (dllexport) int ripple_circ(long object, int cx, int cy, int o, int w, int change, int amnt) {RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;    DWORD rowsize;    DWORD width, height;    LPBYTE row;    int i, e, d, sx, sy, ex, ey;float ratio;    if(!bitmap) return false;    width = bitmap -> infoheader -> biWidth;    height = bitmap -> infoheader -> biHeight;    rowsize = width * 4;    row = (LPBYTE) (bitmap -> firstRow);ratio = 0.0;sx = max(cx - amnt, 0);sy = max(cy - amnt, 0);ex = min(cx + amnt, width);ey = min(cy + amnt, height);double* sins = new double[w];for (i = 0;i < w;i++) {sins[i] = change * sin(M_PI * 3 / 2 + ((float)((i + o) % w)) * M_PI * 2 / w) / 100;}row -= rowsize * sy;row += 4 * sx;    for ( i = sy; i < (int)ey; i++) {        LPBYTE thisrow = row;        for ( e = sx; e < (int)ex; e++) {d = (int)sqrt((pow((float)e - cx, 2)) + (pow((float)i - cy, 2)));if (d > amnt) {thisrow += 4;continue;}ratio = 1 + sins[d % w];thisrow[0] = max(min(thisrow[0] * ratio, 255), 0);thisrow[1] = max(min(thisrow[1] * ratio, 255), 0);thisrow[2] = max(min(thisrow[2] * ratio, 255), 0);            thisrow += 4;        }        row -= rowsize;    }free(sins);    return true;} extern "C" _declspec (dllexport) BOOL negative(long object){    RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;    DWORD rowsize;    DWORD width, height;    LPBYTE row;    int i, e;    if(!bitmap) return false;    width = bitmap -> infoheader -> biWidth;    height = bitmap -> infoheader -> biHeight;    rowsize = width * 4;    row = (LPBYTE) (bitmap -> firstRow);    for ( i = 0; i < (int)height; i++) {        LPBYTE thisrow = row;        for ( e = 0; e < (int)width; e++) {thisrow[0] = (255 - thisrow[0]);thisrow[1] = (255 - thisrow[1]);thisrow[2] = (255 - thisrow[2]);            thisrow += 4;        }        row -= rowsize;    }    return true;} extern "C" _declspec (dllexport) BOOL draw_circle(long object, int cx, int cy, int rad, int thick, int start_angle, int end_angle, int r, int g, int b, int a) {int error, x, y;int radb, errorb, xb, yb;int t;int ang;start_angle %= 360;while (start_angle < 0) {start_angle += 360;}end_angle %= 360;while (end_angle < 0) {end_angle += 360;}if (end_angle == 0 && start_angle == 0) {end_angle = 360;} rad -= 1;    error = -rad;    x = rad;y = 0;radb = rad - 1;errorb = -radb;xb = radb;yb = 0;if (rad == 0) {fill_rect(object, cx, cy, 1, 1, r, g, b, a);return true;}    while (x >= y) {t = x - xb;ang = 61 * y / rad;if ((end_angle > start_angle && end_angle >= 270 - ang && start_angle <= 270 - ang) || (end_angle < start_angle && (end_angle >= 270 - ang || start_angle <= 270 - ang))) {fill_rect(object, cx + x + 1 - t, cy + y, t, 1, r, g, b, a);}if (x != 0 && ((end_angle > start_angle && end_angle >= 90 + ang && start_angle <= 90 + ang) || (end_angle < start_angle && (end_angle >= 90 + ang || start_angle <= 90 + ang)))) {fill_rect(object, cx - x, cy + y, t, 1, r, g, b, a);}if (y != 0 && ((end_angle > start_angle && end_angle >= 270 + ang && start_angle <= 270 + ang) || (end_angle < start_angle && (end_angle >= 270 + ang || start_angle <= 270 + ang)))) {fill_rect(object, cx + x + 1 - t, cy - y, t, 1, r, g, b, a);}if (x != 0 && y != 0 && ((end_angle > start_angle && end_angle >= 90 - ang && start_angle <= 90 - ang) || (end_angle < start_angle && (end_angle >= 90 - ang || start_angle <= 90 - ang)))) {fill_rect(object, cx - x, cy - y, t, 1, r, g, b, a);}if (x != y) {if ((end_angle > start_angle && end_angle >= 180 + ang && start_angle <= 180 + ang) || (end_angle < start_angle && (end_angle >= 180 + ang || start_angle <= 180 + ang))) {fill_rect(object, cx + y, cy + x + 1 - t, 1, t, r, g, b, a);}if ((end_angle > start_angle && end_angle >= 180 - ang && start_angle <= 180 - ang) || (end_angle < start_angle && (end_angle >= 180 - ang || start_angle <= 180 - ang))) {fill_rect(object, cx - y, cy + x + 1 - t, 1, t, r, g, b, a);}if ((end_angle > start_angle && end_angle >= 360 - ang && start_angle <= 360 - ang) || (end_angle < start_angle && (end_angle >= 360 - ang || start_angle <= 360 - ang))) {fill_rect(object, cx + y, cy - x, 1, t, r, g, b, a);}if ((end_angle > start_angle && end_angle >= ang && start_angle <= ang) || (end_angle < start_angle && (end_angle >= ang || start_angle <= ang))) {fill_rect(object, cx - y, cy - x, 1, t, r, g, b, a);}}error += y;errorb += yb;y += 1;yb += 1;error += y;errorb += yb;if (error >= 0) {error -= x;x -= 1;error -= x;}if (errorb >= 0) {errorb -= xb;xb -= 1;errorb -= xb;}    }if (thick > 1) draw_circle(object, cx, cy, rad, thick - 1, start_angle, end_angle, r, g, b, a);return true;} extern "C" _declspec (dllexport) int draw_ellipse(long object, int cx, int cy, int rx, int ry, int thick, int start_angle, int end_angle, int r, int g, int b, int a) {int rxb = rx - 1, ryb = ry - 1;int rx2 = rx * rx, rxb2 = rxb * rxb;    int ry2 = ry * ry, ryb2 = ryb * ryb;    int tworx2 = 2 * rx2, tworxb2 = 2 * rxb2;    int twory2 = 2 * rx2, tworyb2 = 2 * ryb2;    int p, pb;    int x = 0, xb = 0;    int y = ry, yb = ryb;    int px = 0, pxb = 0;    int py = tworx2 * y, pyb = tworxb2 * yb;int t;int ne1, ne2;//int ang;     /* Plot the initial point in each quadrant. */    fill_rect(object, cx + x, cy + y, 1, 1, r, g, b, a);    fill_rect(object, cx - x, cy + y, 1, 1, r, g, b, a);    fill_rect(object, cx + x, cy - y, 1, 1, r, g, b, a);    fill_rect(object, cx - x, cy - y, 1, 1, r, g, b, a);     /* Region 1 */    p = round(ry2 - (rx2 * ry) + (0.25 * rx2));pb = round(ryb2 - (rxb2 * ryb) + (0.25 * rxb2));ne1 = 0;ne2 = 0;    while (px < py) {bool extra = false;if (pxb >= pyb) extra = true;        x++;xb++;        px += twory2;pxb += tworyb2;if (extra) ne1++;        if (p < 0)p += ry2 + px;        else {y--;py -= tworx2;p += ry2 + px - py;        }if (pb < 0)pb += ryb2 + pxb;else {yb--;pyb -= tworxb2;pb += ryb2 + pxb - pyb;if (extra) ne2++;}t = y - yb;        fill_rect(object, cx + x, cy + y + 1 - t, 1, t, r, g, b, a);fill_rect(object, cx - x, cy + y + 1 - t, 1, t, r, g, b, a);fill_rect(object, cx + x, cy - y, 1, t, r, g, b, a);fill_rect(object, cx - x, cy - y, 1, t, r, g, b, a);    } xb -= ne1;pxb -= tworyb2 * ne1;yb += ne2;pyb += tworxb2 * ne2;     /* Region 2 */    p = round(ry2 * (x+0.5) * (x+0.5) + rx2 * (y-1) * (y-1) - rx2 * ry2);pb = round(ryb2 * (xb+0.5) * (xb+0.5) + rxb2 * (yb-1) * (yb-1) - rxb2 * ryb2);    while (y > 0) {        y--;yb--;        py -= tworx2;pyb -= tworxb2;        if (p > 0)p += rx2 - py;        else {x++;px += twory2;p += rx2 - py + px;        }        if (pb > 0)pb += rxb2 - pyb;        else {xb++;pxb += tworyb2;pb += rxb2 - pyb + pxb;        }t = x - xb;        fill_rect(object, cx + x + 1 - t, cy + y, t, 1, r, g, b, a);fill_rect(object, cx - x, cy + y, t, 1, r, g, b, a);fill_rect(object, cx + x + 1 - t, cy - y, t, 1, r, g, b, a);fill_rect(object, cx - x, cy - y, t, 1, r, g, b, a);    } if (thick > 1) {draw_ellipse(object, cx, cy, rxb, ryb, thick - 1, start_angle, end_angle, r, g, b, a);} return true;} void get_radial_average2(int width, int height, LPBYTE row, int x, int y, int cx, int cy, float scale, int amnt, int* col, int* avg, int* tp, int mr, int wc) {int rscale;int curx, cury, error, ystep, xstep;int x1, y1, deltax, deltay;bool steep;if (wc > 0) {long rr = 2.0 * sqrt((double)x * x * height * height + (double)y * y * width * width);//rr = scale * rr;//rr -= rr % mr;rscale = scale * rr / mr;} else {rscale = scale;}LPBYTE thisrow;int rowsize = width * 4;avg[0] = 0;avg[1] = 0;avg[2] = 0;avg[3] = 0;avg[4] = 0;//int ex, ey;//ex = round(x * rscale + cx);//ey = round(y * rscale + cy);if (rscale != 0) {deltax = -x;deltay = -y;x1 = x + cx;y1 = y + cy;steep = fabs((float)(deltay)) > fabs((float)(deltax));if (steep) {int tmp;tmp = x1;x1 = y1;y1 = tmp;tmp = deltax;deltax = deltay;deltay = tmp;}ystep = deltay / fabs((float)(deltay));xstep = deltax / fabs((float)(deltax));deltay = fabs((float)(deltay));deltax = fabs((float)(deltax));error = deltax / 2; curx = x1;cury = y1;for (int i = 0;i < rscale;i++) {if (steep) {if (curx < height && curx >= 0 && cury < width && cury >= 0) {thisrow = row;thisrow -= curx * rowsize;thisrow += cury * 4;avg[0] += thisrow[2];avg[1] += thisrow[1];avg[2] += thisrow[0];avg[3] += thisrow[3];avg[4]++;} else {break;}} else {if (cury < height && cury >= 0 && curx < width && curx >= 0) {thisrow = row;thisrow -= cury * rowsize;thisrow += curx * 4;avg[0] += thisrow[2];avg[1] += thisrow[1];avg[2] += thisrow[0];avg[3] += thisrow[3];avg[4]++;} else {break;}}error -= deltay;if (error < 0) {cury += ystep;error += deltax;if ((steep && cury == width / 2 + ystep) || (!steep && cury == height / 2 + ystep)) break;}curx += xstep;if ((!steep && curx == width / 2 + xstep) || (steep && curx == height / 2 + xstep)) break;}}thisrow = row;thisrow -= (y + cy) * rowsize;thisrow += (x + cx) * 4;if (avg[4] == 0) {col[0] = thisrow[2];col[1] = thisrow[1];col[2] = thisrow[0];col[3] = thisrow[3];return;}col[0] = avg[0] / avg[4];col[1] = avg[1] / avg[4];col[2] = avg[2] / avg[4];col[3] = avg[3] / avg[4];//col[0] = col[0] * amnt / 100 + thisrow[2] * (100 - amnt) / 100;//col[1] = col[1] * amnt / 100 + thisrow[1] * (100 - amnt) / 100;//col[2] = col[2] * amnt / 100 + thisrow[0] * (100 - amnt) / 100;//col[3] = col[3] * amnt / 100 + thisrow[3] * (100 - amnt) / 100;} extern "C" _declspec (dllexport) bool radial_blur(long object, long source, int scale, int amnt, int wc) {RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;RGSSBMINFO *src = ((RGSSBITMAP*) (source << 1)) -> bm -> bminfo;int cx, cy, i, e;int* col = new int[4];int* avg = new int[5];int* tp = new int[4];int rowsize;int mr;    int width, height, sw, sh;    LPBYTE row, sr;    if(!bitmap) return false;    width = bitmap -> infoheader -> biWidth;    height = bitmap -> infoheader -> biHeight;sw = src -> infoheader -> biWidth;sh = src -> infoheader -> biHeight;if(width != sw || height != sh) return false;    rowsize = width * 4;    sr = (LPBYTE) (src -> firstRow);    row = (LPBYTE) (bitmap -> firstRow);cx = width / 2;cy = height / 2;mr = height * width;// * sqrt(cx * cx + cy * cy);for ( i = 0; i < height; i++) {        LPBYTE thisrow = row;        for ( e = 0; e < width; e++) {            get_radial_average2(sw, sh, sr, e - cx, i - cy, cx, cy, scale, amnt, col, avg, tp, mr, wc);thisrow[2] = (int) col[0];thisrow[1] = (int) col[1];thisrow[0] = (int) col[2];thisrow[3] = (int) col[3];            thisrow += 4;        }        row -= rowsize;    }    return true;} extern "C" _declspec (dllexport) bool table_lookup(long object, int* table, int ua) {RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;    DWORD rowsize;    DWORD width, height;    LPBYTE row;    int i, e;    if(!bitmap) return false;    width = bitmap -> infoheader -> biWidth;    height = bitmap -> infoheader -> biHeight;    rowsize = width * 4;    row = (LPBYTE) (bitmap -> firstRow);    for ( i = 0; i < (int)height; i++) {        LPBYTE thisrow = row;        for ( e = 0; e < (int)width; e++) {thisrow[0] = max(min(table[thisrow[0]], 255), 0);thisrow[1] = max(min(table[thisrow[1]], 255), 0);thisrow[2] = max(min(table[thisrow[2]], 255), 0);if (ua > 0) thisrow[3] = max(min(table[thisrow[3]], 255), 0);            thisrow += 4;        }        row -= rowsize;    }    return true;} void get_rect_average(int width, int height, LPBYTE row, int x, int y, int w, int h, int* avg) {    int i, e;int rowsize;LPBYTE row2;if(x>width) x = width;if(y>height) y = height;if(x<0) x = 0;if(y<0) y = 0;if(x+w>width) w = width - x;if(y+h>height) h = height - y;if(w<0) return;if(h<0) return;    rowsize = width * 4;row2 = row;//row2 -= rowsize * y;    for ( i = y; i < y + h; i++) {        LPBYTE thisrow = row2;//thisrow += 4 * x;        for ( e = x; e < x + w; e++) {            avg[0] += thisrow[2];            avg[1] += thisrow[1];            avg[2] += thisrow[0];            avg[3] += thisrow[3];avg[4]++;            thisrow += 4;        }        row2 -= rowsize;    }} extern "C" _declspec (dllexport) bool pixelize(long object, int sizex, int sizey) {int* avg = new int[5];RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;int width, height;LPBYTE row, thisrow;int rowsize;int i, e, nw, nh;//, x, y;if(!bitmap) return false;width = bitmap -> infoheader -> biWidth;height = bitmap -> infoheader -> biHeight;rowsize = width * 4;nw = ceil((float) width / sizex);nh = ceil((float) height / sizey);row = (LPBYTE) (bitmap -> firstRow);//row = mr;for ( e = 0; e < nh; e++) {thisrow = row;for ( i = 0; i < nw; i++) {avg[0] = 0;avg[1] = 0;avg[2] = 0;avg[3] = 0;avg[4] = 0;get_rect_average(width, height, thisrow, i * sizex, e * sizey, sizex, sizey, avg);avg[0] /= avg[4];avg[1] /= avg[4];avg[2] /= avg[4];avg[3] /= avg[4];fill_rect2(width, height, thisrow, i * sizex, e * sizey, sizex, sizey, avg[0], avg[1], avg[2], avg[3]);thisrow += 4 * sizex;/*row = mr;row -= rowsize * e * sizey;for (y = 0;y < min(sizey, height - e * sizey);y++) {thisrow = row;thisrow += i * sizex * 4;for (x = 0;x < min(sizex, width - i * sizex);x++) {thisrow[0] = avg[2];thisrow[1] = avg[1];thisrow[2] = avg[0];thisrow[3] = avg[3];thisrow += 4;}row -= rowsize;}*///thisrow[0] = max(min(table[thisrow[0]], 255), 0);//thisrow[1] = max(min(table[thisrow[1]], 255), 0);//thisrow[2] = max(min(table[thisrow[2]], 255), 0);//if (ua > 0) thisrow[3] = max(min(table[thisrow[3]], 255), 0);        }row -= rowsize * sizey;    }    return true;} extern "C" _declspec (dllexport) void get_pixels(long object, int* pixels) {//int* pixels;RGSSBMINFO *bitmap = ((RGSSBITMAP*) (object<<1)) -> bm -> bminfo;    int rowsize;    int width, height;    LPBYTE row;    int i, e;    //int red, green, blue;    if(!bitmap) return;    width = bitmap -> infoheader -> biWidth;    height = bitmap -> infoheader -> biHeight;//pixels = new int[width * height * 4];    rowsize = width * 4;    row = (LPBYTE) (bitmap -> firstRow);    for ( i = 0; i < height; i++) {        LPBYTE thisrow = row;        for ( e = 0; e < width; e++) {pixels[e * height * 4 + i * 4] = thisrow[2];pixels[e * height * 4 + i * 4 + 1] = thisrow[1];pixels[e * height * 4 + i * 4 + 2] = thisrow[0];pixels[e * height * 4 + i * 4 + 3] = thisrow[3];            thisrow += 4;        }        row -= rowsize;    }}
 
Last edited by a moderator:

scanti

Warper
Member
Joined
Jan 29, 2013
Messages
4
Reaction score
3
First Language
English
Primarily Uses
I see you've been working hard. :thumbsup-left:

I've decided to set up a git repository for the library. Is it OK if I add your code to the library?

You can browse (and fork) the library here.

You can download the latest binary file from here.
 
Joined
May 21, 2012
Messages
83
Reaction score
4
First Language
English
Primarily Uses
Sure, this is a good time for me to start using GitHub (my brother constantly tries to force me to start using it).

Edit - Your transform function looks pretty good, except for the fact that it works backwards, basically reversing the transformation that it takes in. And you should make the parameters for the matrix floats and after you take them in divide each by another argument so you can have decimal values.

Edit - And a little side note: be sure to build the dll with visual studio, as dlls built with mingw don't work on XP professional because of the enhanced security settings.
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,986
Members
137,561
Latest member
visploo100
Top