impgraph.cxx (cb0a2370) impgraph.cxx (ff494be3)
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

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

549
550 aRetBmp = rRetBmpEx.GetBitmap( &aReplaceColor );
551
552 if(rParameters.getSizePixel().Width() || rParameters.getSizePixel().Height())
553 aRetBmp.Scale(rParameters.getSizePixel());
554 }
555 else if( ( meType != GRAPHIC_DEFAULT ) && ImplIsSupportedGraphic() )
556 {
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

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

549
550 aRetBmp = rRetBmpEx.GetBitmap( &aReplaceColor );
551
552 if(rParameters.getSizePixel().Width() || rParameters.getSizePixel().Height())
553 aRetBmp.Scale(rParameters.getSizePixel());
554 }
555 else if( ( meType != GRAPHIC_DEFAULT ) && ImplIsSupportedGraphic() )
556 {
557 // calculate size
558 VirtualDevice aVDev;
559 Size aDrawSize(aVDev.LogicToPixel(maMetaFile.GetPrefSize(), maMetaFile.GetPrefMapMode()));
560
561 if(rParameters.getSizePixel().Width() && rParameters.getSizePixel().Height())
557 if(maEx.IsEmpty())
562 {
558 {
563 // apply given size if exists
564 aDrawSize = rParameters.getSizePixel();
565 }
559 // calculate size
560 VirtualDevice aVDev;
561 Size aDrawSize(aVDev.LogicToPixel(maMetaFile.GetPrefSize(), maMetaFile.GetPrefMapMode()));
566
562
567 if(aDrawSize.Width() && aDrawSize.Height() && !rParameters.getUnlimitedSize()
568 && (aDrawSize.Width() > GRAPHIC_MTFTOBMP_MAXEXT || aDrawSize.Height() > GRAPHIC_MTFTOBMP_MAXEXT))
569 {
570 // limit bitmap size to a maximum of GRAPHIC_MTFTOBMP_MAXEXT x GRAPHIC_MTFTOBMP_MAXEXT
571 double fWH((double)aDrawSize.Width() / (double)aDrawSize.Height());
572
573 if(fWH <= 1.0)
563 if(rParameters.getSizePixel().Width() && rParameters.getSizePixel().Height())
574 {
564 {
575 aDrawSize.setWidth(basegfx::fround(GRAPHIC_MTFTOBMP_MAXEXT * fWH));
576 aDrawSize.setHeight(GRAPHIC_MTFTOBMP_MAXEXT);
565 // apply given size if exists
566 aDrawSize = rParameters.getSizePixel();
577 }
567 }
578 else
568
569 if(aDrawSize.Width() && aDrawSize.Height() && !rParameters.getUnlimitedSize()
570 && (aDrawSize.Width() > GRAPHIC_MTFTOBMP_MAXEXT || aDrawSize.Height() > GRAPHIC_MTFTOBMP_MAXEXT))
579 {
571 {
580 aDrawSize.setWidth(GRAPHIC_MTFTOBMP_MAXEXT);
581 aDrawSize.setHeight(basegfx::fround(GRAPHIC_MTFTOBMP_MAXEXT / fWH));
572 // limit bitmap size to a maximum of GRAPHIC_MTFTOBMP_MAXEXT x GRAPHIC_MTFTOBMP_MAXEXT
573 double fWH((double)aDrawSize.Width() / (double)aDrawSize.Height());
574
575 if(fWH <= 1.0)
576 {
577 aDrawSize.setWidth(basegfx::fround(GRAPHIC_MTFTOBMP_MAXEXT * fWH));
578 aDrawSize.setHeight(GRAPHIC_MTFTOBMP_MAXEXT);
579 }
580 else
581 {
582 aDrawSize.setWidth(GRAPHIC_MTFTOBMP_MAXEXT);
583 aDrawSize.setHeight(basegfx::fround(GRAPHIC_MTFTOBMP_MAXEXT / fWH));
584 }
582 }
585 }
583 }
584
586
585 // calculate pixel size. Normally, it's the same as aDrawSize, but may
586 // need to be extended when hairlines are on the right or bottom edge
587 Size aPixelSize(aDrawSize);
587 // calculate pixel size. Normally, it's the same as aDrawSize, but may
588 // need to be extended when hairlines are on the right or bottom edge
589 Size aPixelSize(aDrawSize);
588
590
589 if(GRAPHIC_GDIMETAFILE == ImplGetType())
590 {
591 // get hairline and full bound rect
592 Rectangle aHairlineRect;
593 const Rectangle aRect(maMetaFile.GetBoundRect(aVDev, &aHairlineRect));
591 if(GRAPHIC_GDIMETAFILE == ImplGetType())
592 {
593 // get hairline and full bound rect
594 Rectangle aHairlineRect;
595 const Rectangle aRect(maMetaFile.GetBoundRect(aVDev, &aHairlineRect));
594
596
595 if(!aRect.IsEmpty() && !aHairlineRect.IsEmpty())
597 if(!aRect.IsEmpty() && !aHairlineRect.IsEmpty())
598 {
599 // expand if needed to allow bottom and right hairlines to be added
600 if(aRect.Right() == aHairlineRect.Right())
601 {
602 aPixelSize.setWidth(aPixelSize.getWidth() + 1);
603 }
604
605 if(aRect.Bottom() == aHairlineRect.Bottom())
606 {
607 aPixelSize.setHeight(aPixelSize.getHeight() + 1);
608 }
609 }
610 }
611
612 if(aVDev.SetOutputSizePixel(aPixelSize))
596 {
613 {
597 // expand if needed to allow bottom and right hairlines to be added
598 if(aRect.Right() == aHairlineRect.Right())
614 if(rParameters.getAntiAliase())
599 {
615 {
600 aPixelSize.setWidth(aPixelSize.getWidth() + 1);
616 aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_ENABLE_B2DDRAW);
601 }
602
617 }
618
603 if(aRect.Bottom() == aHairlineRect.Bottom())
619 if(rParameters.getSnapHorVerLines())
604 {
620 {
605 aPixelSize.setHeight(aPixelSize.getHeight() + 1);
621 aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_PIXELSNAPHAIRLINE);
606 }
622 }
607 }
608 }
609
623
610 if(aVDev.SetOutputSizePixel(aPixelSize))
611 {
612 if(rParameters.getAntiAliase())
613 {
614 aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_ENABLE_B2DDRAW);
615 }
624 ImplDraw( &aVDev, Point(), aDrawSize );
616
625
617 if(rParameters.getSnapHorVerLines())
618 {
619 aVDev.SetAntialiasing(aVDev.GetAntialiasing() | ANTIALIASING_PIXELSNAPHAIRLINE);
626 // use maEx as local buffer for rendered metafile
627 const_cast< ImpGraphic* >(this)->maEx = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() );
620 }
628 }
621
622 ImplDraw( &aVDev, Point(), aDrawSize );
623 aRetBmp = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() );
624 }
629 }
630
631 aRetBmp = maEx.GetBitmap();
625 }
626
627 if( !!aRetBmp )
628 {
629 aRetBmp.SetPrefMapMode( ImplGetPrefMapMode() );
630 aRetBmp.SetPrefSize( ImplGetPrefSize() );
631 }
632

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

649
650 aRetBmpEx = ( mpAnimation ? mpAnimation->GetBitmapEx() : maEx );
651
652 if(rParameters.getSizePixel().Width() || rParameters.getSizePixel().Height())
653 aRetBmpEx.Scale(rParameters.getSizePixel());
654 }
655 else if( ( meType != GRAPHIC_DEFAULT ) && ImplIsSupportedGraphic() )
656 {
632 }
633
634 if( !!aRetBmp )
635 {
636 aRetBmp.SetPrefMapMode( ImplGetPrefMapMode() );
637 aRetBmp.SetPrefSize( ImplGetPrefSize() );
638 }
639

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

656
657 aRetBmpEx = ( mpAnimation ? mpAnimation->GetBitmapEx() : maEx );
658
659 if(rParameters.getSizePixel().Width() || rParameters.getSizePixel().Height())
660 aRetBmpEx.Scale(rParameters.getSizePixel());
661 }
662 else if( ( meType != GRAPHIC_DEFAULT ) && ImplIsSupportedGraphic() )
663 {
657 const ImpGraphic aMonoMask( maMetaFile.GetMonochromeMtf( COL_BLACK ) );
658 aRetBmpEx = BitmapEx(ImplGetBitmap(rParameters), aMonoMask.ImplGetBitmap(rParameters));
664 if(maEx.IsEmpty())
665 {
666 const ImpGraphic aMonoMask( maMetaFile.GetMonochromeMtf( COL_BLACK ) );
667
668 // use maEx as local buffer for rendered metafile
669 const_cast< ImpGraphic* >(this)->maEx = BitmapEx(ImplGetBitmap(rParameters), aMonoMask.ImplGetBitmap(rParameters));
670 }
671
672 aRetBmpEx = maEx;
659 }
660
661 return aRetBmpEx;
662}
663
664// ------------------------------------------------------------------------
665
666Animation ImpGraphic::ImplGetAnimation() const

--- 1277 unchanged lines hidden ---
673 }
674
675 return aRetBmpEx;
676}
677
678// ------------------------------------------------------------------------
679
680Animation ImpGraphic::ImplGetAnimation() const

--- 1277 unchanged lines hidden ---