added get-argb-pixels to bitmap class

svn: r4731
This commit is contained in:
Matthew Flatt 2006-11-01 06:54:04 +00:00
parent 322789559c
commit a996df1d2b
5 changed files with 80 additions and 1 deletions

View File

@ -300,6 +300,7 @@
(define-function set-editor-print-margin)
(define-function get-editor-print-margin)
(define-class bitmap% object% #f
get-argb-pixels
get-gl-config
set-gl-config
set-loaded-mask

View File

@ -162,6 +162,12 @@ static Bool IsColor(wxBitmap *bm)
return (bm->GetDepth() != 1);
}
extern void wxGetARGBPixels(wxBitmap *bm, double x, double y, int w, int h, char *s, Bool get_alpha);
@ -222,6 +228,42 @@ os_wxBitmap::~os_wxBitmap()
objscheme_destroy(this, (Scheme_Object *) __gc_external);
}
static Scheme_Object *os_wxBitmapwxGetARGBPixels(int n, Scheme_Object *p[])
{
WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
REMEMBER_VAR_STACK();
objscheme_check_valid(os_wxBitmap_class, "get-argb-pixels in bitmap%", n, p);
double x0;
double x1;
int x2;
int x3;
wbstring x4 INIT_NULLED_OUT;
Bool x5;
SETUP_VAR_STACK_REMEMBERED(2);
VAR_STACK_PUSH(0, p);
VAR_STACK_PUSH(1, x4);
x0 = WITH_VAR_STACK(objscheme_unbundle_double(p[POFFSET+0], "get-argb-pixels in bitmap%"));
x1 = WITH_VAR_STACK(objscheme_unbundle_double(p[POFFSET+1], "get-argb-pixels in bitmap%"));
x2 = WITH_VAR_STACK(objscheme_unbundle_integer_in(p[POFFSET+2], 0, 10000, "get-argb-pixels in bitmap%"));
x3 = WITH_VAR_STACK(objscheme_unbundle_integer_in(p[POFFSET+3], 0, 10000, "get-argb-pixels in bitmap%"));
x4 = (wbstring)WITH_VAR_STACK(objscheme_unbundle_mutable_bstring(p[POFFSET+4], "get-argb-pixels in bitmap%"));
if (n > (POFFSET+5)) {
x5 = WITH_VAR_STACK(objscheme_unbundle_bool(p[POFFSET+5], "get-argb-pixels in bitmap%"));
} else
x5 = FALSE;
{ if (!((wxBitmap *)((Scheme_Class_Object *)THEOBJ)->primdata)->Ok()) WITH_VAR_STACK(scheme_arg_mismatch(METHODNAME("bitmap%","get-argb-pixels"), "bad bitmap: ", THEOBJ)); }if (SCHEME_BYTE_STRTAG_VAL(p[4+POFFSET]) < (x2 * x3 * 4)) WITH_VAR_STACK(scheme_arg_mismatch(METHODNAME("bitmap%","get-argb-pixels"), "byte string too short: ", p[4+POFFSET]));
WITH_VAR_STACK(wxGetARGBPixels(((wxBitmap *)((Scheme_Class_Object *)p[0])->primdata), x0, x1, x2, x3, x4, x5));
READY_TO_RETURN;
return scheme_void;
}
static Scheme_Object *os_wxBitmapGetGLConfig(int n, Scheme_Object *p[])
{
WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
@ -589,8 +631,9 @@ void objscheme_setup_wxBitmap(Scheme_Env *env)
wxREGGLOB(os_wxBitmap_class);
os_wxBitmap_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "bitmap%", "object%", (Scheme_Method_Prim *)os_wxBitmap_ConstructScheme, 11));
os_wxBitmap_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "bitmap%", "object%", (Scheme_Method_Prim *)os_wxBitmap_ConstructScheme, 12));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxBitmap_class, "get-argb-pixels" " method", (Scheme_Method_Prim *)os_wxBitmapwxGetARGBPixels, 5, 6));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxBitmap_class, "get-gl-config" " method", (Scheme_Method_Prim *)os_wxBitmapGetGLConfig, 0, 0));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxBitmap_class, "set-gl-config" " method", (Scheme_Method_Prim *)os_wxBitmapSetGLConfig, 1, 1));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxBitmap_class, "set-loaded-mask" " method", (Scheme_Method_Prim *)os_wxBitmapSetMask, 1, 1));

View File

@ -22,10 +22,17 @@ static Bool IsColor(wxBitmap *bm)
return (bm->GetDepth() != 1);
}
extern void wxGetARGBPixels(wxBitmap *bm, double x, double y, int w, int h, char *s, Bool get_alpha);
@CLASSBASE wxBitmap "bitmap" : "object"
@MACRO STRINGENOUGH = if (SCHEME_BYTE_STRTAG_VAL(p[POFFSET]) < (((x1 * x2) + 7) >> 3)) WITH_VAR_STACK(scheme_arg_mismatch(METHODNAME("bitmap%","initialization"), "byte string too short: ", p[POFFSET]));
@MACRO ARGBSTRINGENOUGH[who] = if (SCHEME_BYTE_STRTAG_VAL(p[4+POFFSET]) < (x2 * x3 * 4)) WITH_VAR_STACK(scheme_arg_mismatch(METHODNAME("bitmap%",<who>), "byte string too short: ", p[4+POFFSET]));
@MACRO CHECKREADOK[who] = { if (!((wxBitmap *)((Scheme_Class_Object *)THEOBJ)->primdata)->Ok()) WITH_VAR_STACK(scheme_arg_mismatch(<who>, "bad bitmap: ", THEOBJ)); }
@MACRO USEALLFUEL[ok] = if (<ok>) WITH_VAR_STACK(scheme_thread_block(0.0));
@CREATOR (bstring////bstring,rint[1|10000],rint[1|10000]); : : /STRINGENOUGH// <> datastring
@ -47,4 +54,6 @@ static Bool IsColor(wxBitmap *bm)
@ "set-gl-config" : void SetGLConfig(wxGLConfig^)
@ "get-gl-config" : wxGLConfig^ GetGLConfig()
@ m "get-argb-pixels" : void wxGetARGBPixels(double,double,rint[0|10000],rint[0|10000],wbstring,bool=FALSE) : : /CHECKREADOK[METHODNAME("bitmap%","get-argb-pixels")]|ARGBSTRINGENOUGH["get-argb-pixels"]
@END

View File

@ -464,6 +464,19 @@ static void dcGetARGBPixels(wxMemoryDC *dc, double x, double y, int w, int h, ch
READY_TO_RETURN;
}
void wxGetARGBPixels(wxBitmap *src, double x, double y, int w, int h, char *s, Bool get_alpha)
{
wxMemoryDC *srcdc;
SETUP_VAR_STACK(1);
VAR_STACK_PUSH(0, srcdc);
srcdc = WITH_VAR_STACK(MakeDC(src));
WITH_VAR_STACK(dcGetARGBPixels(srcdc, x, y, w, h, (char *)s, get_alpha));
WITH_VAR_STACK(UnmakeDC(srcdc));
READY_TO_RETURN;
}
static void dcSetARGBPixels(wxMemoryDC *dc, double x, double y, int w, int h, char *s, Bool set_alpha)
{
int i, j, p;

View File

@ -330,6 +330,19 @@ static void dcGetARGBPixels(wxMemoryDC *dc, double x, double y, int w, int h, ch
READY_TO_RETURN;
}
void wxGetARGBPixels(wxBitmap *src, double x, double y, int w, int h, char *s, Bool get_alpha)
{
wxMemoryDC *srcdc;
SETUP_VAR_STACK(1);
VAR_STACK_PUSH(0, srcdc);
srcdc = WITH_VAR_STACK(MakeDC(src));
WITH_VAR_STACK(dcGetARGBPixels(srcdc, x, y, w, h, (char *)s, get_alpha));
WITH_VAR_STACK(UnmakeDC(srcdc));
READY_TO_RETURN;
}
static void dcSetARGBPixels(wxMemoryDC *dc, double x, double y, int w, int h, char *s, Bool set_alpha)
{
int i, j, p;