SourceForge logo
SourceForge logo
Menu

matplotlib-checkins

From: <ef...@us...> - 2008年09月01日 22:50:49
Revision: 6060
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6060&view=rev
Author: efiring
Date: 2008年09月01日 22:50:47 +0000 (2008年9月01日)
Log Message:
-----------
Allocate acols, arows only if needed; change suggested by Mike D.
Other slight cleanups in _image.cpp.
Modified Paths:
--------------
 trunk/matplotlib/src/_image.cpp
Modified: trunk/matplotlib/src/_image.cpp
===================================================================
--- trunk/matplotlib/src/_image.cpp	2008年09月01日 22:27:07 UTC (rev 6059)
+++ trunk/matplotlib/src/_image.cpp	2008年09月01日 22:50:47 UTC (rev 6060)
@@ -711,7 +711,7 @@
 size_t numrows = (size_t)Py::Int(args[0]);
 size_t numcols = (size_t)Py::Int(args[1]);
 
- if (numrows > 1 << 15 || numcols > 1 << 15) {
+ if (numrows >= 32768 || numcols >= 32768) {
 throw Py::RuntimeError("numrows and numcols must both be less than 32768");
 }
 
@@ -1088,7 +1088,7 @@
 size_t x = Py::Int(args[1]);
 size_t y = Py::Int(args[2]);
 
- if (x > 1 << 15 || y > 1 << 15) {
+ if (x >= 32768 || y >= 32768) {
 throw Py::ValueError("x and y must both be less than 32768");
 }
 
@@ -1335,7 +1335,7 @@
 PyMem_Free(arows);
 return;
 }
- 
+
 Py::Object
 _image_module::pcolor(const Py::Tuple& args) {
 _VERBOSE("_image_module::pcolor");
@@ -1352,7 +1352,7 @@
 Py::Tuple bounds = args[5];
 unsigned int interpolation = Py::Int(args[6]);
 
- if (rows > 1 << 15 || cols > 1 << 15) {
+ if (rows >= 32768 || cols >= 32768) {
 throw Py::ValueError("rows and cols must both be less than 32768");
 }
 
@@ -1370,11 +1370,11 @@
 // Check we have something to output to
 if (rows == 0 || cols ==0)
 throw Py::ValueError("Cannot scale to zero size");
- 
+
 PyArrayObject *x = NULL; PyArrayObject *y = NULL; PyArrayObject *d = NULL;
 unsigned int * rowstarts = NULL; unsigned int*colstarts = NULL;
 float *acols = NULL; float *arows = NULL;
- 
+
 // Get numpy arrays
 x = (PyArrayObject *) PyArray_ContiguousFromObject(xp.ptr(), PyArray_FLOAT, 1, 1);
 if (x == NULL) {
@@ -1406,14 +1406,12 @@
 
 // Allocate memory for pointer arrays
 rowstarts = reinterpret_cast<unsigned int*>(PyMem_Malloc(sizeof(unsigned int)*rows));
- arows = reinterpret_cast<float *>(PyMem_Malloc(sizeof(float)*rows));
- if (rowstarts == NULL || arows == NULL ) {
+ if (rowstarts == NULL) {
 _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
 throw Py::MemoryError("Cannot allocate memory for lookup table");
 }
 colstarts = reinterpret_cast<unsigned int*>(PyMem_Malloc(sizeof(unsigned int)*cols));
- acols = reinterpret_cast<float*>(PyMem_Malloc(sizeof(float)*cols));
- if (colstarts == NULL || acols == NULL) {
+ if (colstarts == NULL) {
 _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
 throw Py::MemoryError("Cannot allocate memory for lookup table");
 }
@@ -1430,8 +1428,8 @@
 _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
 throw Py::MemoryError("Could not allocate memory for image");
 }
- 
 
+
 // Calculate the pointer arrays to map input x to output x
 unsigned int i, j;
 unsigned int * colstart = colstarts;
@@ -1451,7 +1449,7 @@
 start = reinterpret_cast<unsigned char*>(d->data);
 int s0 = d->strides[0];
 int s1 = d->strides[1];
- 
+
 if(interpolation == Image::NEAREST) {
 _bin_indices_middle(colstart, cols, xs1, nx,dx,x_min);
 _bin_indices_middle(rowstart, rows, ys1, ny, dy,y_min);
@@ -1473,11 +1471,22 @@
 }
 }
 else if(interpolation == Image::BILINEAR) {
+ arows = reinterpret_cast<float *>(PyMem_Malloc(sizeof(float)*rows));
+ if (arows == NULL ) {
+ _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
+ throw Py::MemoryError("Cannot allocate memory for lookup table");
+ }
+ acols = reinterpret_cast<float*>(PyMem_Malloc(sizeof(float)*cols));
+ if (acols == NULL) {
+ _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
+ throw Py::MemoryError("Cannot allocate memory for lookup table");
+ }
+
 _bin_indices_middle_linear(acols, colstart, cols, xs1, nx,dx,x_min);
 _bin_indices_middle_linear(arows, rowstart, rows, ys1, ny, dy,y_min);
 double a00,a01,a10,a11,alpha,beta;
- 
- 
+
+
 agg::int8u * start00;
 agg::int8u * start01;
 agg::int8u * start10;
@@ -1489,12 +1498,12 @@
 {
 alpha=arows[i];
 beta=acols[j];
- 
+
 a00=alpha*beta;
 a01=alpha*(1.0-beta);
 a10=(1.0-alpha)*beta;
 a11=1.0-a00-a01-a10;
- 
+
 start00=(agg::int8u *)(start + s0*rowstart[i] + s1*colstart[j]);
 start01=start00+s1;
 start10=start00+s0;
@@ -1506,22 +1515,18 @@
 position += 4;
 }
 }
- 
+
 }
 
-
- // Attatch output buffer to output buffer
+ // Attach output buffer to output buffer
 imo->rbufOut = new agg::rendering_buffer;
 imo->bufferOut = buffer;
 imo->rbufOut->attach(imo->bufferOut, imo->colsOut, imo->rowsOut, imo->colsOut * imo->BPP);
 
- 
 _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
 
 return Py::asObject(imo);
- 
 
- 
 }
 
 
@@ -1548,7 +1553,7 @@
 Py::Tuple bounds = args[5];
 Py::Object bgp = args[6];
 
- if (rows > 1 << 15 || cols > 1 << 15) {
+ if (rows >= 32768 || cols >= 32768) {
 throw Py::ValueError("rows and cols must both be less than 32768");
 }
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2010年06月16日 17:08:52
Revision: 8439
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8439&view=rev
Author: mdboom
Date: 2010年06月16日 17:08:43 +0000 (2010年6月16日)
Log Message:
-----------
Fix accessing uninitialized memory error.
Modified Paths:
--------------
 trunk/matplotlib/src/_image.cpp
Modified: trunk/matplotlib/src/_image.cpp
===================================================================
--- trunk/matplotlib/src/_image.cpp	2010年06月15日 19:32:24 UTC (rev 8438)
+++ trunk/matplotlib/src/_image.cpp	2010年06月16日 17:08:43 UTC (rev 8439)
@@ -44,7 +44,7 @@
 Image::Image() :
 bufferIn(NULL), rbufIn(NULL), colsIn(0), rowsIn(0),
 bufferOut(NULL), rbufOut(NULL), colsOut(0), rowsOut(0), BPP(4),
- interpolation(BILINEAR), aspect(ASPECT_FREE), bg(1,1,1,0) {
+ interpolation(BILINEAR), aspect(ASPECT_FREE), bg(1,1,1,0), resample(true) {
 _VERBOSE("Image::Image");
 }
 
@@ -196,7 +196,7 @@
 std::pair<agg::int8u*,bool> bufpair = _get_output_buffer();
 
 Py::Object ret = Py::asObject(Py_BuildValue("lls#", rowsOut, colsOut,
-					 bufpair.first, colsOut*rowsOut*4));
+ bufpair.first, colsOut*rowsOut*4));
 
 if (bufpair.second) delete [] bufpair.first;
 return ret;
@@ -229,7 +229,7 @@
 
 agg::rendering_buffer rtmp;
 rtmp.attach(reinterpret_cast<unsigned char*>(buf), colsOut, rowsOut,
-	 row_len);
+ row_len);
 
 switch (format) {
 case 0:
@@ -259,7 +259,7 @@
 args.verify_length(0);
 int row_len = colsOut * 4;
 PyObject* o = Py_BuildValue("lls#", rowsOut, colsOut,
-			 rbufOut, row_len * rowsOut);
+ rbufOut, row_len * rowsOut);
 return Py::asObject(o);
 }
 
@@ -362,9 +362,9 @@
 typedef agg::span_allocator<agg::rgba8> span_alloc_type;
 span_alloc_type sa;
 agg::rgba8 background(agg::rgba8(int(255*bg.r),
-				 int(255*bg.g),
-				 int(255*bg.b),
-				 int(255*bg.a)));
+ int(255*bg.g),
+ int(255*bg.b),
+ int(255*bg.a)));
 
 // the image path
 agg::path_storage path;
@@ -396,11 +396,11 @@
 
 case NEAREST:
 {
-	typedef agg::span_image_filter_rgba_nn<img_accessor_type, interpolator_type> span_gen_type;
-	typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
-	span_gen_type sg(ia, interpolator);
-	renderer_type ri(rb, sa, sg);
-	agg::render_scanlines(ras, sl, ri);
+ typedef agg::span_image_filter_rgba_nn<img_accessor_type, interpolator_type> span_gen_type;
+ typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
+ span_gen_type sg(ia, interpolator);
+ renderer_type ri(rb, sa, sg);
+ agg::render_scanlines(ras, sl, ri);
 }
 break;
 
@@ -414,22 +414,22 @@
 case HAMMING: filter.calculate(agg::image_filter_hamming(), norm); break;
 case HERMITE: filter.calculate(agg::image_filter_hermite(), norm); break;
 }
-	if (resample)
-	 {
-	 typedef agg::span_image_resample_rgba_affine<img_accessor_type> span_gen_type;
-	 typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
-	 span_gen_type sg(ia, interpolator, filter);
-	 renderer_type ri(rb, sa, sg);
-	 agg::render_scanlines(ras, sl, ri);
-	 }
-	else
-	 {
-	 typedef agg::span_image_filter_rgba_2x2<img_accessor_type, interpolator_type> span_gen_type;
-	 typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
-	 span_gen_type sg(ia, interpolator, filter);
-	 renderer_type ri(rb, sa, sg);
-	 agg::render_scanlines(ras, sl, ri);
-	 }
+ if (resample)
+ {
+ typedef agg::span_image_resample_rgba_affine<img_accessor_type> span_gen_type;
+ typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
+ span_gen_type sg(ia, interpolator, filter);
+ renderer_type ri(rb, sa, sg);
+ agg::render_scanlines(ras, sl, ri);
+ }
+ else
+ {
+ typedef agg::span_image_filter_rgba_2x2<img_accessor_type, interpolator_type> span_gen_type;
+ typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
+ span_gen_type sg(ia, interpolator, filter);
+ renderer_type ri(rb, sa, sg);
+ agg::render_scanlines(ras, sl, ri);
+ }
 }
 break;
 case BILINEAR:
@@ -463,22 +463,22 @@
 case LANCZOS: filter.calculate(agg::image_filter_lanczos(radius), norm); break;
 case BLACKMAN: filter.calculate(agg::image_filter_blackman(radius), norm); break;
 }
-	if (resample)
-	 {
-	 typedef agg::span_image_resample_rgba_affine<img_accessor_type> span_gen_type;
-	 typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
-	 span_gen_type sg(ia, interpolator, filter);
-	 renderer_type ri(rb, sa, sg);
-	 agg::render_scanlines(ras, sl, ri);
-	 }
-	else
-	 {
-	 typedef agg::span_image_filter_rgba<img_accessor_type, interpolator_type> span_gen_type;
-	 typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
-	 span_gen_type sg(ia, interpolator, filter);
-	 renderer_type ri(rb, sa, sg);
-	 agg::render_scanlines(ras, sl, ri);
-	 }
+ if (resample)
+ {
+ typedef agg::span_image_resample_rgba_affine<img_accessor_type> span_gen_type;
+ typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
+ span_gen_type sg(ia, interpolator, filter);
+ renderer_type ri(rb, sa, sg);
+ agg::render_scanlines(ras, sl, ri);
+ }
+ else
+ {
+ typedef agg::span_image_filter_rgba<img_accessor_type, interpolator_type> span_gen_type;
+ typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type;
+ span_gen_type sg(ia, interpolator, filter);
+ renderer_type ri(rb, sa, sg);
+ agg::render_scanlines(ras, sl, ri);
+ }
 }
 break;
 
@@ -660,7 +660,7 @@
 behaviors().supportSetattr();
 
 add_varargs_method( "apply_rotation", &Image::apply_rotation, Image::apply_rotation__doc__);
- add_varargs_method( "apply_scaling",	&Image::apply_scaling, Image::apply_scaling__doc__);
+ add_varargs_method( "apply_scaling", &Image::apply_scaling, Image::apply_scaling__doc__);
 add_varargs_method( "apply_translation", &Image::apply_translation, Image::apply_translation__doc__);
 add_keyword_method( "as_rgba_str", &Image::as_rgba_str, Image::as_rgba_str__doc__);
 add_varargs_method( "color_conv", &Image::color_conv, Image::color_conv__doc__);
@@ -744,25 +744,25 @@
 size_t ind=0;
 for (size_t j=0; j<thisim->rowsOut; j++) {
 for (size_t i=0; i<thisim->colsOut; i++) {
-	thisx = i+ox;
+ thisx = i+ox;
 
-	if (isflip)
-	 thisy = thisim->rowsOut - j + oy;
-	else
-	 thisy = j+oy;
+ if (isflip)
+ thisy = thisim->rowsOut - j + oy;
+ else
+ thisy = j+oy;
 
 
-	if (thisx>=numcols || thisy>=numrows) {
-	 ind +=4;
-	 continue;
-	}
+ if (thisx>=numcols || thisy>=numrows) {
+ ind +=4;
+ continue;
+ }
 
-	pixfmt::color_type p;
-	p.r = *(thisim->bufferOut+ind++);
-	p.g = *(thisim->bufferOut+ind++);
-	p.b = *(thisim->bufferOut+ind++);
-	p.a = *(thisim->bufferOut+ind++);
-	pixf.blend_pixel(thisx, thisy, p, 255);
+ pixfmt::color_type p;
+ p.r = *(thisim->bufferOut+ind++);
+ p.g = *(thisim->bufferOut+ind++);
+ p.b = *(thisim->bufferOut+ind++);
+ p.a = *(thisim->bufferOut+ind++);
+ pixf.blend_pixel(thisx, thisy, p, 255);
 }
 }
 }
@@ -854,20 +854,20 @@
 
 for (size_t rownum=0; rownum<imo->rowsIn; rownum++) {
 for (size_t colnum=0; colnum<imo->colsIn; colnum++) {
-	offset = rownum*A->strides[0] + colnum*A->strides[1];
-	r = *(double *)(A->data + offset);
-	g = *(double *)(A->data + offset + A->strides[2] );
-	b = *(double *)(A->data + offset + 2*A->strides[2] );
+ offset = rownum*A->strides[0] + colnum*A->strides[1];
+ r = *(double *)(A->data + offset);
+ g = *(double *)(A->data + offset + A->strides[2] );
+ b = *(double *)(A->data + offset + 2*A->strides[2] );
 
-	if (rgba)
-	 alpha = *(double *)(A->data + offset + 3*A->strides[2] );
-	else
-	 alpha = 1.0;
+ if (rgba)
+ alpha = *(double *)(A->data + offset + 3*A->strides[2] );
+ else
+ alpha = 1.0;
 
-	*buffer++ = int(255*r); // red
-	*buffer++ = int(255*g); // green
-	*buffer++ = int(255*b); // blue
-	*buffer++ = int(255*alpha); // alpha
+ *buffer++ = int(255*r); // red
+ *buffer++ = int(255*g); // green
+ *buffer++ = int(255*b); // blue
+ *buffer++ = int(255*alpha); // alpha
 
 }
 }
@@ -963,19 +963,19 @@
 const size_t N = imo->rowsIn * imo->colsIn;
 size_t i = 0;
 while (i<N) {
-	r = *(double *)(A->data++);
-	g = *(double *)(A->data++);
-	b = *(double *)(A->data++);
+ r = *(double *)(A->data++);
+ g = *(double *)(A->data++);
+ b = *(double *)(A->data++);
 
-	if (rgba)
-	 alpha = *(double *)(A->data++);
-	else
-	 alpha = 1.0;
+ if (rgba)
+ alpha = *(double *)(A->data++);
+ else
+ alpha = 1.0;
 
-	*buffer++ = int(255*r); // red
-	*buffer++ = int(255*g); // green
-	*buffer++ = int(255*b); // blue
-	*buffer++ = int(255*alpha); // alpha
+ *buffer++ = int(255*r); // red
+ *buffer++ = int(255*g); // green
+ *buffer++ = int(255*b); // blue
+ *buffer++ = int(255*alpha); // alpha
 
 }
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2010年06月22日 19:31:03
Revision: 8456
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8456&view=rev
Author: mdboom
Date: 2010年06月22日 19:30:57 +0000 (2010年6月22日)
Log Message:
-----------
Fix severe slowness with very high image magnification.
Modified Paths:
--------------
 trunk/matplotlib/src/_image.cpp
Modified: trunk/matplotlib/src/_image.cpp
===================================================================
--- trunk/matplotlib/src/_image.cpp	2010年06月22日 16:30:24 UTC (rev 8455)
+++ trunk/matplotlib/src/_image.cpp	2010年06月22日 19:30:57 UTC (rev 8456)
@@ -353,6 +353,7 @@
 agg::rasterizer_scanline_aa<> ras;
 agg::scanline_u8 sl;
 
+ ras.clip_box(0, 0, numcols, numrows);
 
 //srcMatrix *= resizingMatrix;
 //imageMatrix *= resizingMatrix;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2010年06月23日 14:18:16
Revision: 8457
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8457&view=rev
Author: mdboom
Date: 2010年06月23日 14:18:05 +0000 (2010年6月23日)
Log Message:
-----------
Do image clipping of images in doubles rather than ints -- prevents the "disappearing image when zooming in too far" problem.
Modified Paths:
--------------
 trunk/matplotlib/src/_image.cpp
Modified: trunk/matplotlib/src/_image.cpp
===================================================================
--- trunk/matplotlib/src/_image.cpp	2010年06月22日 19:30:57 UTC (rev 8456)
+++ trunk/matplotlib/src/_image.cpp	2010年06月23日 14:18:05 UTC (rev 8457)
@@ -29,6 +29,7 @@
 #include "agg_span_image_filter_rgb.h"
 #include "agg_span_image_filter_rgba.h"
 #include "agg_span_interpolator_linear.h"
+#include "agg_rasterizer_sl_clip.h"
 #include "util/agg_color_conv_rgb8.h"
 #include "_image.h"
 #include "mplutils.h"
@@ -350,7 +351,7 @@
 pixfmt pixf(*rbufOut);
 renderer_base rb(pixf);
 rb.clear(bg);
- agg::rasterizer_scanline_aa<> ras;
+ agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip_dbl> ras;
 agg::scanline_u8 sl;
 
 ras.clip_box(0, 0, numcols, numrows);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2011年02月09日 07:45:24
Revision: 8966
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8966&view=rev
Author: efiring
Date: 2011年02月09日 07:45:18 +0000 (2011年2月09日)
Log Message:
-----------
_image.cpp: speed up image_frombyte; patch by C. Gohlke
Non-contiguous arrays, such as those resulting from pan and zoom,
are handled efficiently without additional copying. This
noticeably speeds up zoom and pan on large images.
Modified Paths:
--------------
 trunk/matplotlib/src/_image.cpp
Modified: trunk/matplotlib/src/_image.cpp
===================================================================
--- trunk/matplotlib/src/_image.cpp	2011年02月09日 04:16:08 UTC (rev 8965)
+++ trunk/matplotlib/src/_image.cpp	2011年02月09日 07:45:18 UTC (rev 8966)
@@ -1085,7 +1085,7 @@
 Py::Object x = args[0];
 int isoutput = Py::Int(args[1]);
 
- PyArrayObject *A = (PyArrayObject *) PyArray_ContiguousFromObject(x.ptr(), PyArray_UBYTE, 3, 3);
+ PyArrayObject *A = (PyArrayObject *) PyArray_FromObject(x.ptr(), PyArray_UBYTE, 3, 3);
 if (A == NULL)
 {
 throw Py::ValueError("Array must have 3 dimensions");
@@ -1104,35 +1104,86 @@
 
 agg::int8u *arrbuf;
 agg::int8u *buffer;
+ agg::int8u *dstbuf;
 
 arrbuf = reinterpret_cast<agg::int8u *>(A->data);
 
 size_t NUMBYTES(imo->colsIn * imo->rowsIn * imo->BPP);
- buffer = new agg::int8u[NUMBYTES];
+ buffer = dstbuf = new agg::int8u[NUMBYTES];
 
 if (buffer == NULL) //todo: also handle allocation throw
 {
 throw Py::MemoryError("_image_module::frombyte could not allocate memory");
 }
 
- const size_t N = imo->rowsIn * imo->colsIn * imo->BPP;
- size_t i = 0;
- if (A->dimensions[2] == 4)
+ if PyArray_ISCONTIGUOUS(A)
 {
- memmove(buffer, arrbuf, N);
+ if (A->dimensions[2] == 4)
+ {
+ memmove(dstbuf, arrbuf, imo->rowsIn * imo->colsIn * 4);
+ }
+ else
+ {
+ size_t i = imo->rowsIn * imo->colsIn;
+ while (i--)
+ {
+ *dstbuf++ = *arrbuf++;
+ *dstbuf++ = *arrbuf++;
+ *dstbuf++ = *arrbuf++;
+ *dstbuf++ = 255;
+ }
+ }
 }
+ else if ((A->strides[1] == 4) && (A->strides[2] == 1))
+ {
+ const size_t N = imo->colsIn * 4;
+ const size_t stride = A->strides[0];
+ for (size_t rownum = 0; rownum < imo->rowsIn; rownum++)
+ {
+ memmove(dstbuf, arrbuf, N);
+ arrbuf += stride;
+ dstbuf += N;
+ }
+ }
+ else if ((A->strides[1] == 3) && (A->strides[2] == 1))
+ {
+ const size_t stride = A->strides[0] - imo->colsIn * 3;
+ for (size_t rownum = 0; rownum < imo->rowsIn; rownum++)
+ {
+ for (size_t colnum = 0; colnum < imo->colsIn; colnum++)
+ {
+ *dstbuf++ = *arrbuf++;
+ *dstbuf++ = *arrbuf++;
+ *dstbuf++ = *arrbuf++;
+ *dstbuf++ = 255;
+ }
+ arrbuf += stride;
+ }
+ }
 else
 {
- while (i < N)
+ PyArrayIterObject *iter;
+ iter = (PyArrayIterObject *)PyArray_IterNew((PyObject *)A);
+ if (A->dimensions[2] == 4)
 {
- memmove(buffer, arrbuf, 3);
- buffer += 3;
- arrbuf += 3;
- *buffer++ = 255;
- i += 4;
+ while (iter->index < iter->size) {
+ *dstbuf++ = *((unsigned char *)iter->dataptr);
+ PyArray_ITER_NEXT(iter);
+ }
 }
- buffer -= N;
- arrbuf -= imo->rowsIn * imo->colsIn;
+ else
+ {
+ while (iter->index < iter->size) {
+ *dstbuf++ = *((unsigned char *)iter->dataptr);
+ PyArray_ITER_NEXT(iter);
+ *dstbuf++ = *((unsigned char *)iter->dataptr);
+ PyArray_ITER_NEXT(iter);
+ *dstbuf++ = *((unsigned char *)iter->dataptr);
+ PyArray_ITER_NEXT(iter);
+ *dstbuf++ = 255;
+ }
+ }
+ Py_DECREF(iter);
 }
 
 if (isoutput)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /