Scaling an Image in GWT

I saw this blog entry, which solves the problem by using a GWT DataResource instead of ImageResource. It turns out that the same technique will actually work with ImageResource, if you use it as follows: Image image = new Image(myImageResource.getURL()); image.setPixelSize(getLength(), getHeight()); To keep aspect ratio calculate it like: Image image = new Image(myImageResource.getURL()); image.setPixelSize(newWidth, … Read more

Image scaling and rotating in C/C++

There are many ways to scale and rotate images. The simplest way to scale is: dest[dx,dy] = src[dx*src_width/dest_width,dy*src_height/dest_height] but this produces blocky effects when increasing the size and loss of detail when reducing the size. There are ways to produce better looking results, for example, bilinear filtering. For rotating, the src pixel location can be … Read more

Crop to fit an svg pattern

To get this to work, you need to understand how objectBoundingBox units work in SVG, and also how preserveAspectRatio works. Object Bounding Box Units The size and content of gradients, patterns and a number of other SVG features can be specified in terms of the size of the object (path, rect, circle) which is being … Read more

c# Image resizing to different size while preserving aspect ratio

This should do it. private void resizeImage(string path, string originalFilename, /* note changed names */ int canvasWidth, int canvasHeight, /* new */ int originalWidth, int originalHeight) { Image image = Image.FromFile(path + originalFilename); System.Drawing.Image thumbnail = new Bitmap(canvasWidth, canvasHeight); // changed parm names System.Drawing.Graphics graphic = System.Drawing.Graphics.FromImage(thumbnail); graphic.InterpolationMode = InterpolationMode.HighQualityBicubic; graphic.SmoothingMode = SmoothingMode.HighQuality; graphic.PixelOffsetMode = … Read more

High Quality Image Scaling Library [closed]

Here’s a nicely commented Image Manipulation helper class that you can look at and use. I wrote it as an example of how to perform certain image manipulation tasks in C#. You’ll be interested in the ResizeImage function that takes a System.Drawing.Image, the width and the height as the arguments. using System; using System.Collections.Generic; using … Read more

How to scale a BufferedImage

AffineTransformOp offers the additional flexibility of choosing the interpolation type. BufferedImage before = getBufferedImage(encoded); int w = before.getWidth(); int h = before.getHeight(); BufferedImage after = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); AffineTransform at = new AffineTransform(); at.scale(2.0, 2.0); AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); after = scaleOp.filter(before, after); The fragment shown illustrates resampling, not cropping; this related … Read more