Changeset 610


Ignore:
Timestamp:
12/12/13 11:30:56 (10 years ago)
Author:
jts21
Message:

Partial tiling implemented

Location:
trunk/src/org/expeditee
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/io/WebParser.java

    r606 r610  
    468468                }
    469469               
    470                 Text text = new Text(out.getName() + " " + width);
     470                Text text = new Text("@i: " + out.getName() + " " + width);
    471471                text.setPosition(x, y);
    472472
     
    475475                float invScale = 1 / pic.getScale();
    476476               
     477                // System.out.println("unscaled crop: " + cropStartX + " " + cropStartY + " " + cropEndX + " " + cropEndY);
     478                // System.out.println("crop: " + cropStartX * invScale + " " + cropStartY * invScale + " " + cropEndX * invScale + " " + cropEndY * invScale);
     479               
    477480                pic.setCrop((int)(cropStartX * invScale), (int)(cropStartY * invScale), (int)(cropEndX * invScale), (int)(cropEndY * invScale));
    478481               
    479                 System.out.println("width = " + width + "  source = " + pic.getSource().getText() + "  scale = " + pic.getScale());
     482                // System.out.println("source = " + pic.getSource().getText());
    480483               
    481484                frame.addItem(pic);
  • trunk/src/org/expeditee/items/Picture.java

    r609 r610  
    323323                }
    324324               
    325                 int siw = (int) (iw * _scale);
    326                 int sih = (int) (ih * _scale);
    327                
    328325                int dX1 = _source.getX();
    329326                int dY1 = _source.getY();
     
    331328                int dY2 = _source.getY() + getHeight();
    332329               
    333                 for(int x = dX1; x < dX2; x += siw) {
    334                         for(int y = dY1; y < dY2; y += sih) {
    335                                 int endX = x + siw;
    336                                 if(endX > dX2) {
    337                                         endX = dX2;
    338                                 }
    339                                 int endY = y + sih;
     330               
     331                int cropStartX = _start.x;
     332                int cropEndX = _end.x;
     333        if(cropEndX > iw) {
     334                cropEndX = iw;
     335        }
     336                for(int x = dX1; x < dX2; ) {
     337                        // end - start = (cropEnd - cropStart) * scale
     338                        // => cropEnd = cropStart + (end - start) / scale
     339                        int w = (int) ((cropEndX - cropStartX) * _scale);
     340                        int endX = x + w;
     341                        if(endX > dX2) {
     342                                endX = dX2;
     343                                cropEndX = cropStartX + (int) ((dX2 - x) / _scale);
     344                        }
     345                       
     346                        int cropStartY = _start.y;
     347                        int cropEndY = _end.y;
     348                if(cropEndY > ih) {
     349                        cropEndY = ih;
     350                }
     351                        for(int y = dY1; y < dY2; ) {
     352                                int h = (int) ((cropEndY - cropStartY) * _scale);
     353                                int endY = y + h;
    340354                                if(endY > dY2) {
    341355                                        endY = dY2;
     356                                        cropEndY = cropStartY + (int) ((dY2 - y) / _scale);
    342357                                }
    343                                 // TODO: handle partial tiling
    344                                 int cropEndX = _end.x;
    345                                 if(cropEndX > iw) {
    346                                         cropEndX = iw;
    347                                 }
    348                                 int cropEndY = _end.y;
    349                                 if(cropEndY > ih) {
    350                                         cropEndY = ih;
    351                                 }
    352                                 g.drawImage(_image, x, y, endX, endY, _start.x, _start.y, cropEndX, cropEndY, _imageObserver);
    353                         }
     358                               
     359                                g.drawImage(_image, x, y, endX, endY, cropStartX, cropStartY, cropEndX, cropEndY, _imageObserver);
     360                               
     361                                cropStartY = 0;
     362                                cropEndY = ih;
     363                               
     364                                y = endY;
     365                        }
     366                       
     367                        cropStartX = 0;
     368                        cropEndX = iw;
     369                       
     370                        x = endX;
    354371                }
    355372        }
     
    515532                _start = new Point(startX, startY);
    516533                _end = new Point(endX, endY);
    517                 scaleCrop();
     534                updateSource();
    518535        }
    519536
Note: See TracChangeset for help on using the changeset viewer.