Revision: 5111
http://skim-app.svn.sourceforge.net/skim-app/?rev=5111&view=rev
Author: hofman
Date: 2009-01-07 17:10:59 +0000 (Wed, 07 Jan 2009)
Log Message:
-----------
don't cut off margin when the foreground reaches up to the margin
Modified Paths:
--------------
trunk/NSBitmapImageRep_SKExtensions.m
Modified: trunk/NSBitmapImageRep_SKExtensions.m
===================================================================
--- trunk/NSBitmapImageRep_SKExtensions.m 2009-01-07 15:41:47 UTC (rev
5110)
+++ trunk/NSBitmapImageRep_SKExtensions.m 2009-01-07 17:10:59 UTC (rev
5111)
@@ -163,13 +163,61 @@
// right margin
for (i = iMax - 1; i > iRight; i--) {
for (j = jTop; j <= jBottom; j++) {
- if (isSignificantPixelFromBitMapData(&bitmap, i, j, MAX(MARGIN, i
- 5), MIN(iMax, i + 1), MAX(MARGIN, j - 5), MIN(jMax, j + 5), backgroundPixel))
{
+ if (isSignificantPixelFromBitMapData(&bitmap, i, j, MAX(MARGIN, i
- 5), MIN(iMax - 1, i + 1), MAX(MARGIN, j - 5), MIN(jMax - 1, j + 5),
backgroundPixel)) {
iRight = i; // final
break;
}
}
}
+ // check top margin if necessary
+ if (jTop == MARGIN) {
+ for (j = 0; j < MARGIN; j++) {
+ for (i = MARGIN; i < iMax; i++) {
+ if (isSignificantPixelFromBitMapData(&bitmap, i, j,
MAX(MARGIN, i - 5), MIN(iMax - 1, i + 5), MAX(0, j - 1), MIN(jMax - 1, j + 5),
backgroundPixel)) {
+ jTop = j; // final
+ break;
+ }
+ }
+ }
+ }
+
+ // check bottom margin if necessary
+ if (jBottom == jMax - 1) {
+ for (j = jMax + MARGIN - 1; j > jMax - 1; j--) {
+ for (i = MARGIN; i < iMax; i++) {
+ if (isSignificantPixelFromBitMapData(&bitmap, i, j,
MAX(MARGIN, i - 5), MIN(iMax - 1, i + 5), MAX(MARGIN, j - 5), MIN(jMax + MARGIN
- 1, j + 1), backgroundPixel)) {
+ jBottom = j; // final
+ break;
+ }
+ }
+ }
+ }
+
+ // check left margin if necessary
+ if (iLeft == MARGIN) {
+ for (i = 0; i < MARGIN; i++) {
+ for (j = jTop; j <= jBottom; j++) {
+ if (isSignificantPixelFromBitMapData(&bitmap, i, j, MAX(0, i -
1), MIN(iMax - 1, i + 5), MAX(MARGIN, j - 5), MIN(jMax - 1, j + 5),
backgroundPixel)) {
+ iLeft = i; // final
+ break;
+ }
+ }
+ }
+ }
+
+ // check right margin if necessary
+ if (iRight == iMax - 1) {
+ for (i = iMax + MARGIN - 1; i > iMax - 1; i--) {
+ for (j = jTop; j <= jBottom; j++) {
+ if (isSignificantPixelFromBitMapData(&bitmap, i, j,
MAX(MARGIN, i - 5), MIN(iMax + MARGIN - 1, i + 1), MAX(MARGIN, j - 5), MIN(jMax
- 1, j + 5), backgroundPixel)) {
+ iRight = i; // final
+ break;
+ }
+ }
+ }
+ }
+
// finally, convert the corners to a bounding rect
return NSMakeRect(iLeft, jMax + MARGIN - jBottom - 1, iRight + 1 - iLeft,
jBottom + 1 - jTop);
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit