• 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
CGImage functions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CGImage functions


  • Subject: CGImage functions
  • From: "koen gogne" <email@hidden>
  • Date: Tue, 15 Nov 2005 08:17:26 +0100

> Hi all,
>
> I'm trying to integrate the new core functionality available in 10.4 in our application.
> One of the functions I use now is CGImageSourceCreateThumbnailAtIndex.
> You'll find a code sample below.
>
> However I find it strange that I can't set a resolution in the thumbnail created.
> I can set kCGImageSourceThumbnailMaxPixelSize,
> and leaving out this setting will make the thumbnail the same size as the original.
> But the resulting thumbnail is always 72 dpi (screen resolution).
>
> Is there a way to set the resolution higher ?
> Is there another function available we can use for this purpose ?
>
> The idea being:
> we have an original image,
> for which we want to make previews at a given resolution.
>
> Kind regards,
> Koen Gogne
>
>
>
>
>
> ### CODE SAMPLE ###
> int main (int argc, const char *argv[])
> {
>     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
> 	NSLog([[NSString alloc] initWithFormat:@"Processing file '%s' to '%s' for thumbtype '%s'.",argv[1], argv[2], argv[3]]);
>
>     NSString *inpath;
>     NSString *outpath;
>
>     inpath = [[[NSString alloc] initWithFormat:@"%s",argv[1]]  stringByExpandingTildeInPath];
>     NSURL * url = [NSURL fileURLWithPath:inpath];
>     CGImageSourceRef source = CGImageSourceCreateWithURL((CFURLRef)url, NULL);
>
>     if (source)
>     {
>         // image thumbnail options
>         //NSDictionary* thumbOpts = [NSDictionary dictionaryWithObjectsAndKeys:
>         //                (id)kCFBooleanTrue, (id)kCGImageSourceCreateThumbnailWithTransform,
>         //                (id)kCFBooleanTrue, (id)kCGImageSourceCreateThumbnailFromImageIfAbsent,
>         //                [NSNumber numberWithInt:128], (id)kCGImageSourceThumbnailMaxPixelSize,
>         //                nil];
>         NSDictionary* thumbOpts = [NSDictionary dictionaryWithObjectsAndKeys:
>                         (id)kCFBooleanTrue, (id)kCGImageSourceCreateThumbnailWithTransform,
>                         (id)kCFBooleanTrue, (id)kCGImageSourceCreateThumbnailFromImageIfAbsent,
>                         nil];
>
> 	CGImageRef image = CGImageSourceCreateThumbnailAtIndex(source, 0, (CFDictionaryRef)thumbOpts);
>
> 	outpath = [[[NSString alloc] initWithFormat:@"%s.jpg",argv[2]]  stringByExpandingTildeInPath];
>  	NSURL * outurl = [NSURL fileURLWithPath: outpath];
> 	CGImageDestinationRef ref = CGImageDestinationCreateWithURL((CFURLRef)outurl, (CFStringRef)@"public.jpeg", 1, NULL);
>
> 	// add image to the ImageIO destination (specify the image we want to save)
> 	CGImageDestinationAddImage(ref, image, NULL);
>
> 	if (!CGImageDestinationFinalize(ref))
> 	{
> 	NSLog([[NSString alloc] initWithString:@"Error writing JPEG file\n"]);
> 	}
>
>   	CFRelease(ref);
> 	CGImageRelease(image);
>     }
>     else  // couldn't make image source for image, so display nothing
>     {
> 		NSLog([[NSString alloc] initWithString:@"Error reading source file\n"]);
>     }
>
>     [pool release];
> 	return 1;
> }
> ### CODE SAMPLE ###
>
>
>


This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information and/or information protected by intellectual property rights.
If you are not the intended recipient, please note that any review, dissemination, disclosure, alteration, printing, copying or transmission of this e-mail and/or any file transmitted with it, is strictly prohibited and may be unlawful.
If you have received this e-mail by mistake, please immediately notify the sender and permanently delete the original as well as any copy of any e-mail and any printout thereof.
We may monitor e-mail to and from our network.

NSS nv
Tieltstraat 167
8740 Pittem
Belgium


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Maximum file name length?
  • Next by Date: Custom OutlineView with finder editing behaviour
  • Previous by thread: mouseMoved when inactive?
  • Next by thread: Custom OutlineView with finder editing behaviour
  • Index(es):
    • Date
    • Thread