« MBS Real Studio Plugi… | Home | Syntax Coloring Impro… »

Tip of the day: Rotate image with CoreImage

This code is both fast and GPU accelerated so it works with huge pictures:
// Rotate image with CoreImage // load image dim f as FolderItem = SpecialFolder.Desktop.Child("test.png") dim image as new CIImageMBS(f) // rotate 45 degree dim n as new NSAffineTransformMBS n.rotateByDegrees(45) dim TransformFilter as new CIFilterAffineTransformMBS TransformFilter.inputImage = image TransformFilter.inputTransform = n // get result dim resultImage as CIImageMBS = TransformFilter.outputImage // for saving to file dim outputImage as NSImageMBS = resultImage.RenderNSImage(false) f = SpecialFolder.Desktop.Child("output.png") dim b as BinaryStream = BinaryStream.Create(f, true) b.Write outputImage.PNGRepresentation // as Real Studio picture object for display dim pic as Picture = outputImage.CopyPictureWithMask Backdrop = pic
24 10 12 - 10:58
No comments

Remember personal info?

Emoticons / Textile

Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.