Blackberry – how to resize image?

You can do this pretty simply using the EncodedImage.scaleImage32() method. You’ll need to provide it with the factors by which you want to scale the width and height (as a Fixed32). Here’s some sample code which determines the scale factor for the width and height by dividing the original image size by the desired size, … 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

Resizing an image in asp.net without losing the image quality

This is the code I use. It supports rotation, and also sets the image resolution to the JPEG standards of 72dpi@24-bit color (by default GDI+ saves images at 96dpi@32-bit color). It also fixes the black/gray border problem that some people experience when resizing images. /// <summary> /// Resizes and rotates an image, keeping the original … 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

Resizing an Image without losing any quality [closed]

As rcar says, you can’t without losing some quality, the best you can do in c# is: Bitmap newImage = new Bitmap(newWidth, newHeight); using (Graphics gr = Graphics.FromImage(newImage)) { gr.SmoothingMode = SmoothingMode.HighQuality; gr.InterpolationMode = InterpolationMode.HighQualityBicubic; gr.PixelOffsetMode = PixelOffsetMode.HighQuality; gr.DrawImage(srcImage, new Rectangle(0, 0, newWidth, newHeight)); }