Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWade Brainerd <wadetb@gmail.com>2008-05-19 07:44:59 (GMT)
committer Wade Brainerd <wadetb@gmail.com>2008-05-19 07:44:59 (GMT)
commit5a426437a6d6bb42ca781be2cb5efbcf279d19ef (patch)
treeaf06f86ae7fd2d9357879a47ddfa483e637eb844 /src
parentb60bfd619cebda212385c397e9aad00e382a6a27 (diff)
Work on zooming & scrolling.
Diffstat (limited to 'src')
-rw-r--r--src/canvas.h370
-rw-r--r--src/colorsc_wrap.cxx93
2 files changed, 403 insertions, 60 deletions
diff --git a/src/canvas.h b/src/canvas.h
index e221b39..6e80f3d 100644
--- a/src/canvas.h
+++ b/src/canvas.h
@@ -1033,87 +1033,337 @@ public:
unsigned short* pixels = (unsigned short*)img->mem;
int pitch = img->bpl/sizeof(unsigned short);
+ // Round to multiple of 2.
+ x &= ~1;
+ y &= ~1;
+ w = (w+1) & ~1;
+ h = (h+1) & ~1;
+
+ // Clip rectangle.
+ if (x < 0)
+ {
+ w += x;
+ x = 0;
+ }
+ if (y < 0)
+ {
+ h += y;
+ y = 0;
+ }
+ if (x+w > (width-1)*2)
+ w = (width-1)*2-x;
+ if (y+h > (height-1)*2)
+ h = (height-1)*2-y;
+
// Translate origin to output location.
- unsigned short* dest_pixels = pixels + y*pitch+x;
-
- int src_x = (x - scroll_x)/2;
- int src_y = (y - scroll_y)/2;
+ int src_x = (x - scroll_x);
+ int src_y = (y - scroll_y);
- if (src_x < 0) src_x = 0;
-
- while (src_y < 0)
+ int csy = src_y;
+ for (int cy = y; cy < y+h; cy += 2)
{
- unsigned short* __restrict row0 = dest_pixels;
- unsigned short* __restrict row1 = dest_pixels + pitch;
- dest_pixels += pitch*2;
- for (int cx = 0; cx < w; cx++)
+ unsigned short* __restrict row0 = &pixels[cy*pitch+x];
+ unsigned short* __restrict row1 = row0 + pitch;
+
+ if (csy < 0 || csy >= height)
+ {
+ for (int cx = 0; cx < w; cx += 2)
+ {
+ unsigned int rgb = 0;
+ row0[0] = rgb;
+ row0[1] = rgb;
+ row1[0] = rgb;
+ row1[1] = rgb;
+ row0 += 2;
+ row1 += 2;
+ }
+ }
+ else
{
- unsigned int rgb = 0;
- row0[0] = rgb;
- row0[1] = rgb;
- row1[0] = rgb;
- row1[1] = rgb;
- row0 += 2;
- row1 += 2;
+ unsigned int* __restrict src = &image[csy*width+src_x];
+
+ int cx = 0;
+ int csx = src_x;
+
+ while (csx < 0 && cx < w)
+ {
+ unsigned int rgb = 0;
+ row0[0] = rgb;
+ row0[1] = rgb;
+ row1[0] = rgb;
+ row1[1] = rgb;
+ row0 += 2;
+ row1 += 2;
+ src++;
+ csx++;
+ cx += 2;
+ }
+
+ if (overlay)
+ {
+ while (csx < width && cx < w)
+ {
+ unsigned int p = *src;
+ p &= ~0x03030303;
+ p >>= 2;
+ unsigned int r = (((p>>16)&0xff)>>3)<<11;
+ unsigned int g = (((p>> 8)&0xff)>>2)<<5;
+ unsigned int b = (((p>> 0)&0xff)>>3);
+ unsigned int rgb = r|g|b;
+ row0[0] = rgb;
+ row0[1] = rgb;
+ row1[0] = rgb;
+ row1[1] = rgb;
+ row0 += 2;
+ row1 += 2;
+ src++;
+ csx++;
+ cx += 2;
+ }
+ }
+ else
+ {
+ while (csx < width && cx < w)
+ {
+ unsigned int p = *src;
+ unsigned int r = (((p>>16)&0xff)>>3)<<11;
+ unsigned int g = (((p>> 8)&0xff)>>2)<<5;
+ unsigned int b = (((p>> 0)&0xff)>>3);
+ unsigned int rgb = r|g|b;
+ row0[0] = rgb;
+ row0[1] = rgb;
+ row1[0] = rgb;
+ row1[1] = rgb;
+ row0 += 2;
+ row1 += 2;
+ src++;
+ csx++;
+ cx += 2;
+ }
+ }
+
+ while (cx < w)
+ {
+ unsigned int rgb = 0;
+ row0[0] = rgb;
+ row0[1] = rgb;
+ row1[0] = rgb;
+ row1[1] = rgb;
+ row0 += 2;
+ row1 += 2;
+ src++;
+ csx++;
+ cx += 2;
+ }
}
- src_y++;
- h--;
+
+ csy++;
}
+ }
- unsigned int* src_pixels = &image[src_y*width+src_x];
+ void blit_4x(GdkImage* img, int x, int y, int w, int h, int scroll_x, int scroll_y, bool overlay)
+ {
+ unsigned short* pixels = (unsigned short*)img->mem;
+ int pitch = img->bpl/sizeof(unsigned short);
- for (int cy = 0; cy < h; cy++)
+ // Clip rectangle.
+ if (x < 0)
{
- unsigned int* __restrict src = src_pixels;
- unsigned short* __restrict row0 = dest_pixels;
- unsigned short* __restrict row1 = dest_pixels + pitch;
- src_pixels += width;
- dest_pixels += pitch*2;
- for (int cx = 0; cx < w; cx++)
- {
- unsigned int p = *src++;
- unsigned int r = (((p>>16)&0xff)>>3)<<11;
- unsigned int g = (((p>> 8)&0xff)>>2)<<5;
- unsigned int b = (((p>> 0)&0xff)>>3);
- unsigned int rgb = r|g|b;
- row0[0] = rgb;
- row0[1] = rgb;
- row1[0] = rgb;
- row1[1] = rgb;
- row0 += 2;
- row1 += 2;
- }
+ w += x;
+ x = 0;
}
-
-/*
- if (overlay)
+ if (y < 0)
+ {
+ h += y;
+ y = 0;
+ }
+
+ x &= ~3;
+ y &= ~3;
+ w = (w) & ~3;
+ h = (h) & ~3;
+
+ if (x+w > (width-7)*4)
+ w = (width-7)*4-x;
+ if (y+h > (height-7)*4)
+ h = (height-7)*4-y;
+
+ // Translate origin to output location.
+ int src_x = (x - scroll_x);
+ int src_y = (y - scroll_y);
+
+ int csy = src_y;
+ for (int cy = y; cy < y+h; cy += 4)
{
+ unsigned short* __restrict row0 = &pixels[cy*pitch+x];
+ unsigned short* __restrict row1 = row0 + pitch;
+ unsigned short* __restrict row2 = row1 + pitch;
+ unsigned short* __restrict row3 = row2 + pitch;
- for (int cy = 0; cy < h; cy++)
+ if (csy < 0 || csy >= height)
{
- unsigned int* __restrict src = &image[(y+cy)*width+x];
- unsigned short* __restrict row0 = &pixels[((y+cy)*2+0)*pitch+x*2];
- unsigned short* __restrict row1 = &pixels[((y+cy)*2+1)*pitch+x*2];
- for (int cx = 0; cx < w; cx++)
+ for (int cx = 0; cx < w; cx += 4)
{
- unsigned int p = *src++;
- p &= ~0x03030303;
- p >>= 2;
- unsigned int r = (((p>>16)&0xff)>>3)<<11;
- unsigned int g = (((p>> 8)&0xff)>>2)<<5;
- unsigned int b = (((p>> 0)&0xff)>>3);
- unsigned int rgb = r|g|b;
+ unsigned int rgb = 0;
row0[0] = rgb;
row0[1] = rgb;
+ row0[2] = rgb;
+ row0[3] = rgb;
row1[0] = rgb;
row1[1] = rgb;
- row0 += 2;
- row1 += 2;
+ row1[2] = rgb;
+ row1[3] = rgb;
+ row2[0] = rgb;
+ row2[1] = rgb;
+ row2[2] = rgb;
+ row2[3] = rgb;
+ row3[0] = rgb;
+ row3[1] = rgb;
+ row3[2] = rgb;
+ row3[3] = rgb;
+ row0 += 4;
+ row1 += 4;
+ row2 += 4;
+ row3 += 4;
}
}
+ else
+ {
+ unsigned int* __restrict src = &image[csy*width+src_x];
+
+ int cx = 0;
+ int csx = src_x;
+
+ while (csx < 0 && cx < w)
+ {
+ unsigned int rgb = 0;
+ row0[0] = rgb;
+ row0[1] = rgb;
+ row0[2] = rgb;
+ row0[3] = rgb;
+ row1[0] = rgb;
+ row1[1] = rgb;
+ row1[2] = rgb;
+ row1[3] = rgb;
+ row2[0] = rgb;
+ row2[1] = rgb;
+ row2[2] = rgb;
+ row2[3] = rgb;
+ row3[0] = rgb;
+ row3[1] = rgb;
+ row3[2] = rgb;
+ row3[3] = rgb;
+ row0 += 4;
+ row1 += 4;
+ row2 += 4;
+ row3 += 4;
+ src++;
+ csx++;
+ cx += 4;
+ }
+
+ if (overlay)
+ {
+ while (csx < width && cx < w)
+ {
+ unsigned int p = *src;
+ p &= ~0x03030303;
+ p >>= 2;
+ unsigned int r = (((p>>16)&0xff)>>3)<<11;
+ unsigned int g = (((p>> 8)&0xff)>>2)<<5;
+ unsigned int b = (((p>> 0)&0xff)>>3);
+ unsigned int rgb = r|g|b;
+ row0[0] = rgb;
+ row0[1] = rgb;
+ row0[2] = rgb;
+ row0[3] = rgb;
+ row1[0] = rgb;
+ row1[1] = rgb;
+ row1[2] = rgb;
+ row1[3] = rgb;
+ row2[0] = rgb;
+ row2[1] = rgb;
+ row2[2] = rgb;
+ row2[3] = rgb;
+ row3[0] = rgb;
+ row3[1] = rgb;
+ row3[2] = rgb;
+ row3[3] = rgb;
+ row0 += 4;
+ row1 += 4;
+ row2 += 4;
+ row3 += 4;
+ src++;
+ csx++;
+ cx += 4;
+ }
+ }
+ else
+ {
+ while (csx < width && cx < w)
+ {
+ unsigned int p = *src;
+ unsigned int r = (((p>>16)&0xff)>>3)<<11;
+ unsigned int g = (((p>> 8)&0xff)>>2)<<5;
+ unsigned int b = (((p>> 0)&0xff)>>3);
+ unsigned int rgb = r|g|b;
+ row0[0] = rgb;
+ row0[1] = rgb;
+ row0[2] = rgb;
+ row0[3] = rgb;
+ row1[0] = rgb;
+ row1[1] = rgb;
+ row1[2] = rgb;
+ row1[3] = rgb;
+ row2[0] = rgb;
+ row2[1] = rgb;
+ row2[2] = rgb;
+ row2[3] = rgb;
+ row3[0] = rgb;
+ row3[1] = rgb;
+ row3[2] = rgb;
+ row3[3] = rgb;
+ row0 += 4;
+ row1 += 4;
+ row2 += 4;
+ row3 += 4;
+ src++;
+ csx++;
+ cx += 4;
+ }
+ }
+
+ while (cx < w)
+ {
+ unsigned int rgb = 0;
+ row0[0] = rgb;
+ row0[1] = rgb;
+ row0[2] = rgb;
+ row0[3] = rgb;
+ row1[0] = rgb;
+ row1[1] = rgb;
+ row1[2] = rgb;
+ row1[3] = rgb;
+ row2[0] = rgb;
+ row2[1] = rgb;
+ row2[2] = rgb;
+ row2[3] = rgb;
+ row3[0] = rgb;
+ row3[1] = rgb;
+ row3[2] = rgb;
+ row3[3] = rgb;
+ row0 += 4;
+ row1 += 4;
+ row2 += 4;
+ row3 += 4;
+ src++;
+ csx++;
+ cx += 4;
+ }
+ }
+
+ csy++;
}
- else
- */
}
//---------------------------------------------------------------------------------------------
diff --git a/src/colorsc_wrap.cxx b/src/colorsc_wrap.cxx
index 6a3b4d2..20918af 100644
--- a/src/colorsc_wrap.cxx
+++ b/src/colorsc_wrap.cxx
@@ -9433,6 +9433,98 @@ fail:
}
+SWIGINTERN PyObject *_wrap_Canvas_blit_4x(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Canvas *arg1 = (Canvas *) 0 ;
+ GdkImage *arg2 = (GdkImage *) 0 ;
+ int arg3 ;
+ int arg4 ;
+ int arg5 ;
+ int arg6 ;
+ int arg7 ;
+ int arg8 ;
+ bool arg9 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int val3 ;
+ int ecode3 = 0 ;
+ int val4 ;
+ int ecode4 = 0 ;
+ int val5 ;
+ int ecode5 = 0 ;
+ int val6 ;
+ int ecode6 = 0 ;
+ int val7 ;
+ int ecode7 = 0 ;
+ int val8 ;
+ int ecode8 = 0 ;
+ bool val9 ;
+ int ecode9 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
+ PyObject * obj5 = 0 ;
+ PyObject * obj6 = 0 ;
+ PyObject * obj7 = 0 ;
+ PyObject * obj8 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOO:Canvas_blit_4x",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Canvas, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Canvas_blit_4x" "', argument " "1"" of type '" "Canvas *""'");
+ }
+ arg1 = reinterpret_cast< Canvas * >(argp1);
+ {
+ // todo- Error checking would be nice.
+ PyGObject* pygo = (PyGObject*)obj1;
+ GdkImage* img = (GdkImage*)pygo->obj;
+ arg2 = img;
+ }
+ ecode3 = SWIG_AsVal_int(obj2, &val3);
+ if (!SWIG_IsOK(ecode3)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Canvas_blit_4x" "', argument " "3"" of type '" "int""'");
+ }
+ arg3 = static_cast< int >(val3);
+ ecode4 = SWIG_AsVal_int(obj3, &val4);
+ if (!SWIG_IsOK(ecode4)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Canvas_blit_4x" "', argument " "4"" of type '" "int""'");
+ }
+ arg4 = static_cast< int >(val4);
+ ecode5 = SWIG_AsVal_int(obj4, &val5);
+ if (!SWIG_IsOK(ecode5)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "Canvas_blit_4x" "', argument " "5"" of type '" "int""'");
+ }
+ arg5 = static_cast< int >(val5);
+ ecode6 = SWIG_AsVal_int(obj5, &val6);
+ if (!SWIG_IsOK(ecode6)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "Canvas_blit_4x" "', argument " "6"" of type '" "int""'");
+ }
+ arg6 = static_cast< int >(val6);
+ ecode7 = SWIG_AsVal_int(obj6, &val7);
+ if (!SWIG_IsOK(ecode7)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "Canvas_blit_4x" "', argument " "7"" of type '" "int""'");
+ }
+ arg7 = static_cast< int >(val7);
+ ecode8 = SWIG_AsVal_int(obj7, &val8);
+ if (!SWIG_IsOK(ecode8)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "Canvas_blit_4x" "', argument " "8"" of type '" "int""'");
+ }
+ arg8 = static_cast< int >(val8);
+ ecode9 = SWIG_AsVal_bool(obj8, &val9);
+ if (!SWIG_IsOK(ecode9)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "Canvas_blit_4x" "', argument " "9"" of type '" "bool""'");
+ }
+ arg9 = static_cast< bool >(val9);
+ (arg1)->blit_4x(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_Canvas_downsize_video(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
Canvas *arg1 = (Canvas *) 0 ;
@@ -11506,6 +11598,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"Canvas_get_num_commands", _wrap_Canvas_get_num_commands, METH_VARARGS, NULL},
{ (char *)"Canvas_play_range", _wrap_Canvas_play_range, METH_VARARGS, NULL},
{ (char *)"Canvas_blit_2x", _wrap_Canvas_blit_2x, METH_VARARGS, NULL},
+ { (char *)"Canvas_blit_4x", _wrap_Canvas_blit_4x, METH_VARARGS, NULL},
{ (char *)"Canvas_downsize_video", _wrap_Canvas_downsize_video, METH_VARARGS, NULL},
{ (char *)"Canvas_videopaint_motion", _wrap_Canvas_videopaint_motion, METH_VARARGS, NULL},
{ (char *)"Canvas_blit_videopaint", _wrap_Canvas_blit_videopaint, METH_VARARGS, NULL},