Revision 54

View differences:

trunk/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/FFrameView.java
440 440
                    draw_h, //(int) rectangleLayout.getHeight(),
441 441
                    BufferedImage.TYPE_INT_ARGB);
442 442

  
443
            Graphics2D gimg = (Graphics2D) m_image.getGraphics();
443
            Graphics2D gimg = (Graphics2D) m_image.createGraphics();
444 444
            
445 445
            /*
446 446
            gimg.translate(-((int) rectangleLayout.getX()),
......
449 449
            
450 450
            try {
451 451
                getMapContext().draw(m_image, gimg, getScale());
452
                gimg.dispose();
452 453
            } catch (ReadException e) {
453 454
                LOG.error("Error reading the provider" , e);
454 455
            } catch (MapContextException mpex) {
......
488 489
     * @param height
489 490
     * @return
490 491
     */
491
    private BufferedImage copyForcingImageSize(Image img, int w, int h) {
492
    private BufferedImage copyForcingImageSize(
493
        BufferedImage disp_img, int w, int h) {
492 494
        
493
        if (img == null || w < 1 || h < 1) {
495
        if (disp_img == null || w < 1 || h < 1) {
494 496
            return new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
495 497
        }
496
        int from_w = img.getWidth(null);
497
        int from_h = img.getHeight(null);
498
        int from_w = disp_img.getWidth(null);
499
        int from_h = disp_img.getHeight(null);
498 500
        if (from_w < 1 || from_h < 1) {
499 501
            return new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
500 502
        }
501 503
        
502 504
        BufferedImage resp =
503 505
            new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
504
        Graphics rg = resp.getGraphics();
506
        Graphics rg = resp.createGraphics();
505 507
        
506 508
        double rat_w = (1d*w) / (1d*from_w);
507 509
        double rat_h = (1d*h) / (1d*from_h);
......
515 517
            // w, target_h
516 518
            offset_w = 0;
517 519
            offset_h = (h - target_h) / 2;
518
            aux = img.getScaledInstance(w, target_h, Image.SCALE_FAST);
520
            aux = disp_img.getScaledInstance(w, target_h, Image.SCALE_FAST);
519 521
            rg.drawImage(aux, offset_w, offset_h, null);
520 522

  
521 523
        } else {
......
524 526
            // target_w, h
525 527
            offset_w = (w - target_w) / 2;
526 528
            offset_h = 0;
527
            aux = img.getScaledInstance(target_w, h, Image.SCALE_FAST);
529
            aux = disp_img.getScaledInstance(target_w, h, Image.SCALE_FAST);
528 530
            rg.drawImage(aux, offset_w, offset_h, null);
529 531
        }
532
        
533
        aux = null;
534
        resp.flush();
535
        rg.dispose();
530 536
        return resp;
531 537
    }
532 538

  

Also available in: Unified diff