• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: vImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vImage


  • Subject: Re: vImage
  • From: Shawn Erickson <email@hidden>
  • Date: Fri, 9 Jan 2004 16:42:33 -0800

On Jan 9, 2004, at 4:01 PM, Amedeo Paglione wrote:

Hi all,

I'm trying to use the vImage library to resize an image but I always get an exception executing the vImageScale_ARGB8888 function.

Here is an extract from the simple test code:

NSBitmapImageRep * theImage = [ NSBitmapImageRep imageRepWithContentsOfFile:filename ];

if( theImage != nil )
{
src = (vImage_Buffer*)malloc(sizeof(vImage_Buffer));
bpp = [ theImage bitsPerPixel]/8;
MyInitBuffer(src, [theImage pixelsHigh], [theImage pixelsWide], bpp);
bytesPRow = [theImage bytesPerRow];

h = [theImage pixelsHigh];
memcpy(src->data, [theImage bitmapData], h * bytesPRow);

dest = (vImage_Buffer*)malloc(sizeof(vImage_Buffer));
MyInitBuffer(dest, 300, 300, bpp );
vImageScale_ARGB8888(src, dest, NULL, 0); // Here it is the ERROR

MyFreeBuffer(dest);
MyFreeBuffer(src);
}

Why the copy? You should just be able to get the pointer to image data and wrap that data with a vImage_Buffer.

Anyway I believe you need to specify something for the flags field, zero is not a valid option for this operation. The docs list the following...

kvImageBackgroundColorFill
If set, the function will use the Background Color Fill technique to access pixels outside the source image.

kvImageEdgeExtend
If set, the function will use the Edge Extend technique to access pixels outside the source image.

kvImageDoNotTile
If set, the function will not do internal tiling. This is appropriate if you do tiling yourself.

kvImageHighQualityResampling
If set, the function will use a Lanczos5 kernel for resampling. Otherwise it will use a Lanczos3 kernel.

The kvImageBackgroundColorFill and kvImageEdgeExtend flags are mutually exclusive. You must set exactly one of these flags. See Pixels Outside the Image Buffer.



I cannot locate the message now but I believe an Apple employee just emailed a code snippet that outlined how to resize an image in Cocoa without resolution loss.

-Shawn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: vImage
      • From: Amedeo Paglione <email@hidden>
References: 
 >vImage (From: Amedeo Paglione <email@hidden>)

  • Prev by Date: Re: Thinking about shareware prices... (was a question about NSDate inside userDefaults)
  • Next by Date: Re: NSWindow's firstResponder and a pointer to that object.
  • Previous by thread: vImage
  • Next by thread: Re: vImage
  • Index(es):
    • Date
    • Thread