]> git.lyx.org Git - features.git/commitdiff
(Rob Lahaye): fix clipping when using the basic image loader.
authorAngus Leeming <leeming@lyx.org>
Mon, 15 Apr 2002 16:56:28 +0000 (16:56 +0000)
committerAngus Leeming <leeming@lyx.org>
Mon, 15 Apr 2002 16:56:28 +0000 (16:56 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3998 a592a061-630c-0410-9148-cb99ea01b6c8

src/graphics/ChangeLog
src/graphics/GraphicsImageXPM.C

index 69a18cb8e405d11012dc0af2db4ae940d292ae00..af276a35d8a40e904d13f44040ede15abd051ee3 100644 (file)
@@ -1,3 +1,6 @@
+2002-04-16  Rob Lahaye  <lahaye@users.sourceforge.net>
+       * GraphicsImageXPM.C: fix clipping for boundingbox y-coordinates
+
 2002-04-08  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * GraphicsCacheItem.C (findTargetFormat): fix bug waiting to bite:
index 37aaec0741b9120825a6cb097e6d016cda204ed3..7289e37154e0b3b5bcfddf28367dfd7ccadd0fca 100644 (file)
@@ -244,11 +244,17 @@ void GImageXPM::clip(GParams const & params)
                return;
 
        dimension * new_data = image_.initialisedData(new_width, new_height);
+       dimension * it = new_data;
+
+       // The image is stored in memory from upper-left to lower-right,
+       // so we loop from yt to yb.
        dimension const * old_data = image_.data();
+       dimension const * start_row = old_data +
+               image_.width() * (image_.height() - params.bb.yt);
 
-       dimension * it = new_data;
-       dimension const * start_row = old_data;
-       for (size_t row = params.bb.yb; row < params.bb.yt; ++row) {
+       // the Bounding Box dimensions are never less than zero, so we can use
+       // "unsigned int row" here
+       for (dimension row = params.bb.yb; row < params.bb.yt; ++row) {
                dimension const * begin = start_row + params.bb.xl;
                dimension const * end   = start_row + params.bb.xr;
                it = std::copy(begin, end, it);