Tag Archives: scaling

Scaling an image in Objective-C (Cocoa Framework)

The UIImage class can be used to represent an image. The following snippet scales an image according to a size which is provided with a CGSize parameter. + (UIImage *)scale:(UIImage *)image toSize:(CGSize)size { UIGraphicsBeginImageContext(size); [image drawInRect:CGRectMake(0, 0, size.width, size.height)]; UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return scaledImage; }

Posted in Objective-C | Also tagged , , , , , , , , , , | Leave a comment

Matrix multiplication in C++

Matrices can be used to perform transformations. For example, in 2D and 3D space. Transformations include, but are not limited to, rotating, scaling and translating. Transformations can be combined by multiplying the matrices with each other. For example, you might want to: scale an object with a factor of 2 rotate it 45 degrees around the [...]

Posted in C++ | Also tagged , , , , , , , , , , , , , | 2 Comments