bitmap.cxx (87bc88d3) bitmap.cxx (e6f63103)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 1370 unchanged lines hidden (view full) ---

1379 Rectangle aRect( rRect );
1380 BitmapReadAccess* pReadAcc = ( (Bitmap*) this )->AcquireReadAccess();
1381
1382 aRect.Intersection( Rectangle( Point(), GetSizePixel() ) );
1383 aRect.Justify();
1384
1385 if( pReadAcc )
1386 {
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 1370 unchanged lines hidden (view full) ---

1379 Rectangle aRect( rRect );
1380 BitmapReadAccess* pReadAcc = ( (Bitmap*) this )->AcquireReadAccess();
1381
1382 aRect.Intersection( Rectangle( Point(), GetSizePixel() ) );
1383 aRect.Justify();
1384
1385 if( pReadAcc )
1386 {
1387 Rectangle aSubRect;
1387 //Rectangle aSubRect;
1388 const long nLeft = aRect.Left();
1389 const long nTop = aRect.Top();
1390 const long nRight = aRect.Right();
1391 const long nBottom = aRect.Bottom();
1392 const BitmapColor aMatch( pReadAcc->GetBestMatchingColor( rColor ) );
1393
1388 const long nLeft = aRect.Left();
1389 const long nTop = aRect.Top();
1390 const long nRight = aRect.Right();
1391 const long nBottom = aRect.Bottom();
1392 const BitmapColor aMatch( pReadAcc->GetBestMatchingColor( rColor ) );
1393
1394 aRegion.ImplBeginAddRect();
1394 //RectangleVector aRectangles;
1395 //aRegion.ImplBeginAddRect();
1396 std::vector< long > aLine;
1397 long nYStart(nTop);
1398 long nY(nTop);
1395
1399
1396 for( long nY = nTop; nY <= nBottom; nY++ )
1400 for( ; nY <= nBottom; nY++ )
1397 {
1401 {
1398 aSubRect.Top() = aSubRect.Bottom() = nY;
1402 //aSubRect.Top() = aSubRect.Bottom() = nY;
1403 std::vector< long > aNewLine;
1404 long nX(nLeft);
1399
1405
1400 for( long nX = nLeft; nX <= nRight; )
1406 for( ; nX <= nRight; )
1401 {
1402 while( ( nX <= nRight ) && ( aMatch != pReadAcc->GetPixel( nY, nX ) ) )
1403 nX++;
1404
1405 if( nX <= nRight )
1406 {
1407 {
1408 while( ( nX <= nRight ) && ( aMatch != pReadAcc->GetPixel( nY, nX ) ) )
1409 nX++;
1410
1411 if( nX <= nRight )
1412 {
1407 aSubRect.Left() = nX;
1413 aNewLine.push_back(nX);
1414 //aSubRect.Left() = nX;
1408
1409 while( ( nX <= nRight ) && ( aMatch == pReadAcc->GetPixel( nY, nX ) ) )
1410 nX++;
1411
1415
1416 while( ( nX <= nRight ) && ( aMatch == pReadAcc->GetPixel( nY, nX ) ) )
1417 nX++;
1418
1412 aSubRect.Right() = nX - 1L;
1413 aRegion.ImplAddRect( aSubRect );
1419 //aSubRect.Right() = nX - 1L;
1420 aNewLine.push_back(nX - 1);
1421
1422 //aRegion.ImplAddRect( aSubRect );
1423 //aRectangles.push_back(aSubRect);
1424 //aRegion.Union(aSubRect);
1414 }
1415 }
1425 }
1426 }
1427
1428 if(aNewLine != aLine)
1429 {
1430 // need to write aLine, it's different from the next line
1431 if(aLine.size())
1432 {
1433 Rectangle aSubRect;
1434
1435 // enter y values and proceed ystart
1436 aSubRect.Top() = nYStart;
1437 aSubRect.Bottom() = nY ? nY - 1 : 0;
1438
1439 for(sal_uInt32 a(0); a < aLine.size();)
1440 {
1441 aSubRect.Left() = aLine[a++];
1442 aSubRect.Right() = aLine[a++];
1443 aRegion.Union(aSubRect);
1444 }
1445 }
1446
1447 // copy line as new line
1448 aLine = aNewLine;
1449 nYStart = nY;
1450 }
1416 }
1417
1451 }
1452
1418 aRegion.ImplEndAddRect();
1453 // write last line if used
1454 if(aLine.size())
1455 {
1456 Rectangle aSubRect;
1457
1458 // enter y values
1459 aSubRect.Top() = nYStart;
1460 aSubRect.Bottom() = nY ? nY - 1 : 0;
1461
1462 for(sal_uInt32 a(0); a < aLine.size();)
1463 {
1464 aSubRect.Left() = aLine[a++];
1465 aSubRect.Right() = aLine[a++];
1466 aRegion.Union(aSubRect);
1467 }
1468 }
1469
1470 //aRegion.ImplEndAddRect();
1471 //aRegion.SetRegionRectangles(aRectangles);
1472
1419 ( (Bitmap*) this )->ReleaseAccess( pReadAcc );
1420 }
1421 else
1422 aRegion = aRect;
1423
1424 return aRegion;
1425}
1426

--- 541 unchanged lines hidden ---
1473 ( (Bitmap*) this )->ReleaseAccess( pReadAcc );
1474 }
1475 else
1476 aRegion = aRect;
1477
1478 return aRegion;
1479}
1480

--- 541 unchanged lines hidden ---