CIFilterLanczosScaleTransformMBS question

How do I control the result of a CIFilterLanczosScaleTransformMBS? I want to scale down large images with the following code:

[code]dim CGImage as CGImageMBS = CGCreateImageMBS(PreviewPic)
dim CIImage as CIImageMBS = NewCIImagewithCGImageMBS(CGImage)

dim w as Integer = CIImage.Extent.Width
dim h as integer = CIImage.Extent.Height

dim filter as new CIFilterLanczosScaleTransformMBS
dim l as integer = max(w,h)

filter.inputImage = CIImage
filter.inputAspectRatio = 1.0
filter.inputScale = 100.0/l

dim img as CIImageMBS = filter.outputImage
dim nimg as NSImageMBS = img.RenderNSImage(false)
dim data as string = nimg.JPEGRepresentationWithCompressionFactor(0.8)

dim resultPic as Picture = Picture.FromData(data)[/code]

But what does inputScale do? The documentation doesn’t say anything - as usual.

I have an image 813:1099. After running the code the result picture is 148:200. But why? I want my result to be 379:512 pixels large. How do I do this?

isn’t that the scale factor?
Why do you use 100/l there?
Maybe better use new width / old width?

The 100/l is directly out of the example “quickly generate previews …”. There is no property scale factor for the filter.

This works for me:

[code]dim CGImage as CGImageMBS = CGCreateImageMBS(XojoBackground)
dim CIImage as CIImageMBS = NewCIImagewithCGImageMBS(CGImage)

dim w as Integer = CIImage.Extent.Width
dim h as integer = CIImage.Extent.Height

dim filter as new CIFilterLanczosScaleTransformMBS
dim l as integer = max(w,h)

filter.inputImage = CIImage
filter.inputAspectRatio = 1.0
filter.inputScale = 512.0 / l

dim img as CIImageMBS = filter.outputImage
dim nimg as NSImageMBS = img.RenderNSImage(false)
dim resultPic as Picture = nimg.CopyPictureWithAlpha

Backdrop = resultPic
Title = str(resultPic.Width) + “x” + str(resultPic.Height)[/code]

This seems to work for me and scales image to 512 pixels.

nimg.JPEGRepresentationWithCompressionFactor is not needed and you can skip the JPEG compression.

Thanks, works fine!