SourceForge logo
SourceForge logo
Menu

matplotlib-checkins

Revision: 3588
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3588&view=rev
Author: mdboom
Date: 2007年07月20日 07:08:58 -0700 (2007年7月20日)
Log Message:
-----------
Make draw_bitmap inner loop faster and prevent segfaults if x and y
are negative.
Modified Paths:
--------------
 branches/mathtext_mgd/src/ft2font.cpp
Modified: branches/mathtext_mgd/src/ft2font.cpp
===================================================================
--- branches/mathtext_mgd/src/ft2font.cpp	2007年07月20日 13:46:20 UTC (rev 3587)
+++ branches/mathtext_mgd/src/ft2font.cpp	2007年07月20日 14:08:58 UTC (rev 3588)
@@ -876,25 +876,28 @@
 return Py::Int(- bbox.yMin);;
 }
 
+#undef	CLAMP
+#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
+
 void
 FT2Font::draw_bitmap( FT_Bitmap* bitmap,
 		 FT_Int x,
 		 FT_Int y) {
 _VERBOSE("FT2Font::draw_bitmap");
 FT_Int i, j, p, q;
- FT_Int x_max = x + bitmap->width;
- FT_Int y_max = y + bitmap->rows;
-
 FT_Int width = (FT_Int)image.width;
 FT_Int height = (FT_Int)image.height;
- for ( i = x, p = 0; i < x_max; i++, p++ )
+
+ FT_Int x1 = CLAMP(x, 0, width);
+ FT_Int y1 = CLAMP(y, 0, height);
+ FT_Int x2 = CLAMP(x + bitmap->width, 0, width);
+ FT_Int y2 = CLAMP(y + bitmap->rows, 0, height);
+
+ for ( i = x1, p = 0; i < x2; ++i, ++p )
 {
- for ( j = y, q = 0; j < y_max; j++, q++ )
+ for ( j = y1, q = 0; j < y2; ++j, ++q )
 	{
-	 if ( i >= width || j >= height )
-	 continue;
-	 image.buffer[i + j*width] |= bitmap->buffer[p + q*bitmap->width];
-
+	 image.buffer[i + j*width] |= bitmap->buffer[p + q*bitmap->pitch];
 	}
 }
 }
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 によって変換されたページ (->オリジナル) /