View | Details | Raw Unified | Return to bug 163123
Collapse All | Expand All

(-)src/org/eclipse/gmf/runtime/draw2d/ui/render/internal/image/ImageRenderedImage.java (-9 / +9 lines)
Lines 73-87 Link Here
73
			int bufferHeight = getKey().getHeight() == 0 ? origHeight : getKey().getHeight();
73
			int bufferHeight = getKey().getHeight() == 0 ? origHeight : getKey().getHeight();
74
			
74
			
75
			int newWidth = bufferWidth;
75
			int newWidth = bufferWidth;
76
			int newHeight = bufferWidth;
76
            int newHeight = bufferHeight;
77
			
77
            
78
			if (getKey().shouldMaintainAspectRatio()) {
78
            if (getKey().shouldMaintainAspectRatio()) {
79
				if (newWidth > newHeight) {
79
                double origAspectRatio = origHeight / (double)origWidth;
80
					newHeight = (int)Math.round(newWidth * origHeight / (double)origWidth);
80
                if (origAspectRatio > newHeight / (double)newWidth) {
81
				}
81
                    newWidth = (int)Math.round(newHeight / origAspectRatio);
82
				else {
82
                } else {
83
					newWidth = (int)Math.round(newHeight * origWidth / (double)origHeight);
83
                    newHeight = (int)Math.round(newWidth * origAspectRatio);
84
				}
84
                }
85
				
85
				
86
				double scale = 1.0;
86
				double scale = 1.0;
87
				if (newWidth > bufferWidth)
87
				if (newWidth > bufferWidth)
(-)src/org/eclipse/gmf/runtime/draw2d/ui/render/awt/internal/svg/ImageTranscoderEx.java (-4 / +9 lines)
Lines 202-211 Link Here
202
			if (Px.isIdentity() && (newWidth != docWidth || newHeight != docHeight)) {
202
			if (Px.isIdentity() && (newWidth != docWidth || newHeight != docHeight)) {
203
				// The document has no viewBox, we need to resize it by hand.
203
				// The document has no viewBox, we need to resize it by hand.
204
				// we want to keep the document size ratio
204
				// we want to keep the document size ratio
205
				float d = Math.max(docWidth, docHeight);
205
				float xscale = newWidth / docWidth;
206
				float dd = Math.max(newWidth, newHeight);
206
                float yscale = newHeight / docHeight;
207
				float scale = dd/d;
207
                if (docHeight / docWidth > newHeight / newWidth) {
208
				Px = AffineTransform.getScaleInstance(scale, scale);
208
                    xscale = yscale;
209
                } else {
210
                    yscale = xscale;
211
                }
212
                
213
				Px = AffineTransform.getScaleInstance(xscale, yscale);
209
			}
214
			}
210
		}
215
		}
211
		else {
216
		else {

Return to bug 163123