Modified:
trunk/wx.mod/wx.mod/common.bmx
trunk/wx.mod/wx.mod/core.bmx
trunk/wx.mod/wx.mod/wxglue.cpp
trunk/wx.mod/wx.mod/wxglue.h
trunk/wx.mod/wxbitmap.mod/common.bmx
trunk/wx.mod/wxbitmap.mod/glue.cpp
trunk/wx.mod/wxbitmap.mod/glue.h
trunk/wx.mod/wxbitmap.mod/wxbitmap.bmx
trunk/wx.mod/wxmax2d.mod/wxmax2d.bmx
Log:
More wxMax2D work.
DrawText now displays properly, with correct transparency.
(This may, or may not, bode well for general images)
Modified: trunk/wx.mod/wx.mod/common.bmx
==============================================================================
--- trunk/wx.mod/wx.mod/common.bmx (original)
+++ trunk/wx.mod/wx.mod/common.bmx Thu Dec 13 01:26:04 2007
@@ -261,6 +261,7 @@
Function bmx_wxcolour_createnamedcolour:Byte Ptr(name:String)
Function bmx_wxcolour_set(handle:Byte Ptr, r:Int, g:Int, b:Int, a:Int)
Function bmx_wxcolour_setasnamedcolour:Int(handle:Byte Ptr, name:String)
+ Function bmx_wxcolour_equals:Int(handle:Byte Ptr, colour:Byte Ptr)
Function bmx_wxstockgdi_colour_black:Byte Ptr()
Function bmx_wxstockgdi_colour_blue:Byte Ptr()
Modified: trunk/wx.mod/wx.mod/core.bmx
==============================================================================
--- trunk/wx.mod/wx.mod/core.bmx (original)
+++ trunk/wx.mod/wx.mod/core.bmx Thu Dec 13 01:26:04 2007
@@ -134,6 +134,10 @@
Return bmx_wxcolour_setasnamedcolour(wxObjectPtr, name)
End Method
+ Method Equals:Int(colour:wxColour)
+ Return bmx_wxcolour_equals(wxObjectPtr, colour.wxObjectPtr)
+ End Method
+
Method Delete()
If wxObjectPtr Then
bmx_wxcolour_delete(wxObjectPtr)
Modified: trunk/wx.mod/wx.mod/wxglue.cpp
==============================================================================
--- trunk/wx.mod/wx.mod/wxglue.cpp (original)
+++ trunk/wx.mod/wx.mod/wxglue.cpp Thu Dec 13 01:26:04 2007
@@ -738,6 +738,10 @@
return new MaxColour(c);
}
+bool bmx_wxcolour_equals(MaxColour * col, MaxColour * other) {
+ return col->Colour() == other->Colour();
+}
+
// **************************
MaxColour * bmx_wxstockgdi_colour_black() {
Modified: trunk/wx.mod/wx.mod/wxglue.h
==============================================================================
--- trunk/wx.mod/wx.mod/wxglue.h (original)
+++ trunk/wx.mod/wx.mod/wxglue.h Thu Dec 13 01:26:04 2007
@@ -161,7 +161,8 @@
MaxColour * bmx_wxcolour_createnamedcolour(BBString * name);
void bmx_wxcolour_set(MaxColour * col, int r, int g, int b, int a);
bool bmx_wxcolour_setasnamedcolour(MaxColour * col, BBString * name);
-
+ bool bmx_wxcolour_equals(MaxColour * col, MaxColour * other);
+
MaxColour * bmx_wxstockgdi_colour_black();
MaxColour * bmx_wxstockgdi_colour_blue();
MaxColour * bmx_wxstockgdi_colour_cyan();
Modified: trunk/wx.mod/wxbitmap.mod/common.bmx
==============================================================================
--- trunk/wx.mod/wxbitmap.mod/common.bmx (original)
+++ trunk/wx.mod/wxbitmap.mod/common.bmx Thu Dec 13 01:26:04 2007
@@ -77,4 +77,6 @@
Function bmx_wxbitmap_createfrompixmap:Byte Ptr(pixels:Byte Ptr,
width:Int, height:Int, pitch:Int, bytesPerPixel:Int, bitsPerPixel:Int)
+ Function bmx_wxbitmap_colourize(bitmap:Byte Ptr, colour:Byte ptr)
+
End Extern
Modified: trunk/wx.mod/wxbitmap.mod/glue.cpp
==============================================================================
--- trunk/wx.mod/wxbitmap.mod/glue.cpp (original)
+++ trunk/wx.mod/wxbitmap.mod/glue.cpp Thu Dec 13 01:26:04 2007
@@ -38,6 +38,9 @@
return bitmap;
}
+void MaxBitmap::SetBitmap(const wxBitmap & b) {
+ bitmap = wxBitmap(b);
+}
// *********************************************
@@ -149,7 +152,7 @@
wxImage image(width, height);
image.InitAlpha();
-
+
unsigned char * data = image.GetData();
for (int row = 0; row < height; row++) {
@@ -161,10 +164,37 @@
data[dpos] = ((unsigned char*)pixels)[ppos];
data[dpos+1] = ((unsigned char*)pixels)[ppos+1];
data[dpos+2] = ((unsigned char*)pixels)[ppos+2];
+
+ image.SetAlpha(col, row, ((unsigned char*)pixels)[ppos+3]);
}
}
return new MaxBitmap(wxBitmap(image));
}
+void bmx_wxbitmap_colourize(MaxBitmap * bitmap, MaxColour * colour) {
+
+ wxImage image = bitmap->Bitmap().ConvertToImage();
+ int width = image.GetWidth();
+ int height = image.GetHeight();
+ unsigned char r = colour->Colour().Red();
+ unsigned char g = colour->Colour().Green();
+ unsigned char b = colour->Colour().Blue();
+
+ unsigned char* data = image.GetData();
+
+ for (int row = 0; row < height; row++) {
+ int drow = row * (3 * width);
+ for (int col = 0; col < width; col++) {
+ int dpos = drow + col * 3;
+
+ data[dpos] &= r;
+ data[dpos+1] &= g;
+ data[dpos+2] &= b;
+ }
+ }
+
+ bitmap->SetBitmap(wxBitmap(image));
+
+}
Modified: trunk/wx.mod/wxbitmap.mod/glue.h
==============================================================================
--- trunk/wx.mod/wxbitmap.mod/glue.h (original)
+++ trunk/wx.mod/wxbitmap.mod/glue.h Thu Dec 13 01:26:04 2007
@@ -64,6 +64,8 @@
MaxBitmap * bmx_wxbitmap_createfrompixmap(void * pixels, int width,
int height, int pitch, int bytesPerPixel, int bitsPerPixel);
+ void bmx_wxbitmap_colourize(MaxBitmap * bitmap, MaxColour * colour);
+
}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -73,6 +75,7 @@
public:
MaxBitmap(const wxBitmap & b = wxNullBitmap);
wxBitmap & Bitmap();
+ void SetBitmap(const wxBitmap & b);
private:
wxBitmap bitmap;
Modified: trunk/wx.mod/wxbitmap.mod/wxbitmap.bmx
==============================================================================
--- trunk/wx.mod/wxbitmap.mod/wxbitmap.bmx (original)
+++ trunk/wx.mod/wxbitmap.mod/wxbitmap.bmx Thu Dec 13 01:26:04 2007
@@ -309,6 +309,13 @@
bmx_wxbitmap_setwidth(wxObjectPtr, width)
End Method
+ Rem
+ bbdoc: Applies @colour to each pixel
+ End Rem
+ Method Colourize(colour:wxColour)
+ bmx_wxbitmap_colourize(wxObjectPtr, colour.wxObjectPtr)
+ End Method
+
Method Delete()
If wxObjectPtr Then
bmx_wxbitmap_delete(wxObjectPtr)
Modified: trunk/wx.mod/wxmax2d.mod/wxmax2d.bmx
==============================================================================
--- trunk/wx.mod/wxmax2d.mod/wxmax2d.bmx (original)
+++ trunk/wx.mod/wxmax2d.mod/wxmax2d.bmx Thu Dec 13 01:26:04 2007
@@ -58,8 +58,13 @@
Field name:Int,seq:Int
Field bitmap:wxBitmap
+
+ Field displayBitmap:wxBitmap
+
Field driver:TwxMax2DDriver
+ Field lastColour:wxColour
+
Method New()
seq=GraphicsSeq
End Method
@@ -75,6 +80,13 @@
Method Draw( x0#,y0#,x1#,y1#,tx#,ty# )
Assert seq=GraphicsSeq Else "Image does not exist"
+
+ If Not lastColour Or Not lastColour.Equals(driver.pen.GetColour()) Then
+ lastColour = driver.pen.GetColour()
+
+ displayBitmap = bitmap.GetSubBitmap(0, 0, bitmap.GetWidth(), bitmap.GetHeight())
+ displayBitmap.Colourize(lastColour)
+ End If
'EnableTex name
'glBegin GL_QUADS
'glTexCoord2f u0,v0
@@ -86,7 +98,7 @@
'glTexCoord2f u0,v1
'glVertex2f x0*ix+y1*iy+tx,x0*jx+y1*jy+ty
'glEnd
- driver.DrawImage(x0, y0, x1, y1, tx, ty, bitmap)
+ driver.DrawImage(x0, y0, x1, y1, tx, ty, displayBitmap)
End Method
Function CreateFromPixmap:TwxImageFrame( src:TPixmap, flags:Int )
@@ -150,8 +162,8 @@
Field clsColor:wxBrush = wxWHITE_BRUSH()
Field brush:wxBrush = wxBLACK_BRUSH()
Field pen:wxPen = wxBLACK_PEN()
- Field textForeground:wxColour = wxBLACK()
- Field textBackground:wxColour = wxWHITE()
+ 'Field textForeground:wxColour = wxBLACK()
+ 'Field textBackground:wxColour = wxWHITE()
Field dc:wxDC = Null
'graphics driver overrides