how it works:
First of all, the function "ImpBmp("image.bmp")" will load up a bitmap in memory (If header information meets specification)
- Code: Select all
void ImpBmp(char*FPath)
{
int BmpHeader[64],i,j;
FILE*BMPF=fopen(FPath, "r+b");
for(i=0; i<64; i++)
{
BmpHeader[i]=fgetc(BMPF);
}
if(BmpHeader[0]==66 && BmpHeader[1]==77)//Checks if this really is a bmp!
{
if(BmpHeader[18]==128 && BmpHeader[22]==128)//Checks if the size is good
{
if(BmpHeader[28]==24)//Checks if it's the correct BPP
{
fseek(BMPF, BmpHeader[10], SEEK_SET);
for(i=127; i>=0; i--)
{
for(j=0; j<128; j++)
{
Wimg_Blue[j][i]=fgetc(BMPF);
Wimg_Green[j][i]=fgetc(BMPF);
Wimg_Red[j][i]=fgetc(BMPF);
}
}
}
}
}
fclose(BMPF);
}
with the bitmap loaded and organised to be more "human readable", you can draw the window with the function "DW_Main(0,0,1,320,240)", which will draw 9 different window component and strech the ones needed to be.
- Code: Select all
void DW_TLC(int W_Xo, int W_Yo, int W_Act) //Top Left Corner
{
int i,j;
for(i=0; i<8; i++)
{
for(j=0; j<16; j++)
{
if(Wimg_Red[0][0]==Wimg_Red[i][j+1+(17*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[i][j+1+(17*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[i][j+1+(17*(1-W_Act))])
{
setpen(0,0,0,1,1);
}
else setpen(Wimg_Red[i][j+1+(17*(1-W_Act))],Wimg_Green[i][j+1+(17*(1-W_Act))],Wimg_Blue[i][j+1+(17*(1-W_Act))],0,1);
putpixel(i+W_Xo,j+W_Yo);
}
}
}
void DW_TTB(int W_Xo, int W_Yo, int W_Act, float W_WWidth) //Top Title Bar
{
int i,j,pi;
for(i=0; i<W_WWidth; i++)
{
for(j=0; j<16; j++)
{
pi=min(63,round((i/W_WWidth)*64));
if(Wimg_Red[0][0]==Wimg_Red[pi+9][j+1+(17*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[pi+9][j+1+(17*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[pi+9][j+1+(17*(1-W_Act))])
{
setpen(0,0,0,1,1);
}
else setpen(Wimg_Red[pi+9][j+1+(17*(1-W_Act))],Wimg_Green[pi+9][j+1+(17*(1-W_Act))],Wimg_Blue[pi+9][j+1+(17*(1-W_Act))],0,1);
putpixel(i+W_Xo+8,j+W_Yo);
}
}
}
void DW_TRC(int W_Xo, int W_Yo, int W_Act, int W_WWidth) //Top Right Corner
{
int i,j;
for(i=0; i<8; i++)
{
for(j=0; j<16; j++)
{
if(Wimg_Red[0][0]==Wimg_Red[i+74][j+1+(17*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[i+74][j+1+(17*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[i+74][j+1+(17*(1-W_Act))])
{
setpen(0,0,0,1,1);
}
else setpen(Wimg_Red[i+74][j+1+(17*(1-W_Act))],Wimg_Green[i+74][j+1+(17*(1-W_Act))],Wimg_Blue[i+74][j+1+(17*(1-W_Act))],0,1);
putpixel(i+W_Xo+W_WWidth+8,j+W_Yo);
}
}
}
void DW_LSB(int W_Xo, int W_Yo, int W_Act, float W_WHeight) //Left Side Border
{
int i,j,pj;
for(i=0; i<6; i++)
{
for(j=0; j<W_WHeight; j++)
{
pj=min(63,round((j/W_WHeight)*64));
if(Wimg_Red[0][0]==Wimg_Red[i+(14*(1-W_Act))][pj+35]&&Wimg_Green[0][0]==Wimg_Green[i+(14*(1-W_Act))][pj+35]&&Wimg_Blue[0][0]==Wimg_Blue[i+(14*(1-W_Act))][pj+35])
{
setpen(0,0,0,1,1);
}
else setpen(Wimg_Red[i+(14*(1-W_Act))][pj+35],Wimg_Green[i+(14*(1-W_Act))][pj+35],Wimg_Blue[i+(14*(1-W_Act))][pj+35],0,1);
putpixel(i+W_Xo,j+W_Yo+16);
}
}
}
void DW_RSB(int W_Xo, int W_Yo, int W_Act, int W_WWidth, float W_WHeight) //Right Side Border
{
int i,j,pj;
for(i=0; i<6; i++)
{
for(j=0; j<W_WHeight; j++)
{
pj=min(63,round((j/W_WHeight)*64));
if(Wimg_Red[0][0]==Wimg_Red[7+i+(14*(1-W_Act))][pj+35]&&Wimg_Green[0][0]==Wimg_Green[7+i+(14*(1-W_Act))][pj+35]&&Wimg_Blue[0][0]==Wimg_Blue[7+i+(14*(1-W_Act))][pj+35])
{
setpen(0,0,0,1,1);
}
else setpen(Wimg_Red[7+i+(14*(1-W_Act))][pj+35],Wimg_Green[7+i+(14*(1-W_Act))][pj+35],Wimg_Blue[7+i+(14*(1-W_Act))][pj+35],0,1);
putpixel(10+i+W_Xo+W_WWidth,j+W_Yo+16);
}
}
}
void DW_BLC(int W_Xo, int W_Yo, int W_Act, int W_WHeight) //Bottom Left Corner
{
int i,j;
for(i=0; i<8; i++)
{
for(j=0; j<8; j++)
{
if(Wimg_Red[0][0]==Wimg_Red[i+28][j+35+(9*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[i+28][j+35+(9*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[i+28][j+35+(9*(1-W_Act))])
{
setpen(0,0,0,1,1);
}
else setpen(Wimg_Red[i+28][j+35+(9*(1-W_Act))],Wimg_Green[i+28][j+35+(9*(1-W_Act))],Wimg_Blue[i+28][j+35+(9*(1-W_Act))],0,1);
putpixel(i+W_Xo,j+W_Yo+W_WHeight+16);
}
}
}
void DW_BRC(int W_Xo, int W_Yo, int W_Act, int W_WWidth, int W_WHeight) //Bottom Right Corner
{
int i,j;
for(i=0; i<8; i++)
{
for(j=0; j<8; j++)
{
if(Wimg_Red[0][0]==Wimg_Red[i+37][j+35+(9*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[i+37][j+35+(9*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[i+37][j+35+(9*(1-W_Act))])
{
setpen(0,0,0,1,1);
}
else setpen(Wimg_Red[i+37][j+35+(9*(1-W_Act))],Wimg_Green[i+37][j+35+(9*(1-W_Act))],Wimg_Blue[i+37][j+35+(9*(1-W_Act))],0,1);
putpixel(i+W_Xo+W_WWidth+8,j+W_Yo+W_WHeight+16);
}
}
}
void DW_BBL(int W_Xo, int W_Yo, int W_Act, float W_WWidth, int W_WHeight) //Bottom Border Line
{
int i,j,pi;
for(i=0; i<W_WWidth; i++)
{
for(j=0; j<6; j++)
{
pi=min(63,round((i/W_WWidth)*64));
if(Wimg_Red[0][0]==Wimg_Red[pi][j+100+(7*(1-W_Act))]&&Wimg_Green[0][0]==Wimg_Green[pi][j+100+(7*(1-W_Act))]&&Wimg_Blue[0][0]==Wimg_Blue[pi][j+100+(7*(1-W_Act))])
{
setpen(0,0,0,1,1);
}
else setpen(Wimg_Red[pi][j+100+(7*(1-W_Act))],Wimg_Green[pi][j+100+(7*(1-W_Act))],Wimg_Blue[pi][j+100+(7*(1-W_Act))],0,1);
putpixel(i+W_Xo+8,j+W_Yo+W_WHeight+18);
}
}
}
void DW_WA(int W_Xo, int W_Yo, float W_WWidth, float W_WHeight) //Working Area
{
int i,j,pi,pj;
if(W_WWidth>0&&W_WHeight>0)
{
for(i=0; i<W_WWidth+4; i++)
{
for(j=0; j<W_WHeight+2; j++)
{
pi=min(63,round((i/W_WWidth)*64));
pj=min(63,round((j/W_WHeight)*64));
setpen(Wimg_Red[pi+46][pj+35],Wimg_Green[pi+46][pj+35],Wimg_Blue[pi+46][pj+35],0,1);
putpixel(i+W_Xo+6,j+W_Yo+16);
}
}
}
}
void DW_Main(int W_Xo, int W_Yo, int W_Act, int W_WWidth, int W_WHeight)
{
DW_TLC(W_Xo,W_Yo,W_Act);
DW_TTB(W_Xo,W_Yo,W_Act,W_WWidth);
DW_TRC(W_Xo,W_Yo,W_Act,W_WWidth);
DW_LSB(W_Xo,W_Yo,W_Act,W_WHeight);
DW_RSB(W_Xo,W_Yo,W_Act,W_WWidth,W_WHeight);
DW_BLC(W_Xo,W_Yo,W_Act,W_WHeight);
DW_BRC(W_Xo,W_Yo,W_Act,W_WWidth,W_WHeight);
DW_BBL(W_Xo,W_Yo,W_Act,W_WWidth,W_WHeight);
DW_WA(W_Xo,W_Yo,W_WWidth,W_WHeight);
}
NOTE: You cannot call DW_Main() before ImpBmp(), well you can, except it'll give out a window completly transparent
how to use:
very simple, put the two top scripts in the GLOBAL SCRIPT
On the view actor -> create actor, do a script:
- Code: Select all
ImpBmp("Default.bmp");//Wait! Make sure you replaced "Default.bmp" with the name of your bitmap!
On a canvas actor when you need to draw a window, call the function "DW_Main(0,0,1,100,100)" in a script, the syntax of the function is as follow: DW_Main(Position Offset on the X axis, Position Offset on the Y axis, 0=Window is inactive; 1=Window is active(Selected), Width of "working" region in window, Height of "working" region in window);
how to create a skin:
Elements in gray are never streched
Elements in yellow are streched along the X axis only
Elements in blue are streched along the Y axis only
Element in green is streched on both axis
Darker elements are inactive
1:Active Top Left Corner, size:8x16 offset:0,1
2:Active Title Bar, Resizable, size:64x16 offset:9,1
3:Active Top Right Corner, size:8x16 offset:74,1
4:Inactive Top Left Corner, size:8x16 offset:0,18
5:Inactive Title Bar, Resizable, size:64x16 offset:9,18
6:Inactive Top Right Corner, size:8x16 offset:74,18
7:Active Left Border, Resizable, size:6x64 offset:0,35
8:Active Right Border, Resizable, size:6x64 offset:7,35
9:Inactive Left Border, Resizable, size:6x64 offset:14,35
A:Inactive Right Border, Resizable, size:6x64 offset:21,35
B:Active Bottom Left Corner, size:8x8 offset:28,35 *
C:Active Bottom Right Corner, size:8x8 offset:37,35 **
D:Inactive Bottom Left Corner, size:8x8 offset:28,44 *
E:Inactive Bottom Right Corner, size:8x8 offset:37,44 **
F:Working Area, Resizable, size:64x64 offset:46,35
10:Active Bottom Border, Resizable, size:64x6 offset:0,100
11:Inactive Bottom Border, Resizable, size:64x6 offset:0,100
*A square of 2x2 pixels gets overlayed by the Working Area on the top right corner of the element
**A square of 2x2 pixels gets overlayed by the Working Area on the top left corner of the element
NOTE: The transparent color is given by the first pixel found (0,0); any pixels matching that one will be considered as a transparent color. Due to this, all elements are placed a pixel lower so it's possible to have no transparency
Enjoy this neat function, and I hope you will like it! no credits needed, but appreciated