Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Objective-c > NSImage batch c...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 907 of 1039
Post > Topic >>

NSImage batch conversion

by zon7 <zon7mail@[EMAIL PROTECTED] > Sep 21, 2007 at 05:35 AM

HI, I've been trying to do a batch converter for images. The problem
is the memory is not being released properly. When the for ends the
memory is ok, but during the for it continues increasing. I have a
function with a for loop:
	for(count=0;count<cant;count++)
	{
		path=[datos objectAtIndex:count];
		save_name=[NSString stringWithFormat:
				@[EMAIL PROTECTED]
"image_%04d.jpg",count+1];
		output=[[batch_outdir stringValue]
stringByAppendingPathComponent:save_name];
		[self convert:path path_out:output format:NSJPEGFileType quality:
0.3];
	}

and then the conversion function

-(void)convert:(NSString*)path_in path_out:(NSString*)path_out format:
(NSBitmapImageFileType)type quality:(float)q
{
	NSDictionary *d=[NSDictionary dictionaryWithObject:
						[NSNumber numberWithFloat:q]
						forKey:NSImageCompressionFactor];
	NSImage	*tmp_img;
	NSBitmapImageRep *b;
	NSData *data;

	tmp_img=[[NSImage alloc] initWithContentsOfFile:path_in];
	b=[NSBitmapImageRep imageRepWithData:[tmp_img TIFFRepresentation]];
	[tmp_img release];

	data=[b representationUsingType:tipo properties:d];
	[data writeToFile:path_out atomically:TRUE];
}
 




 2 Posts in Topic:
NSImage batch conversion
zon7 <zon7mail@[EMAIL   2007-09-21 05:35:53 
Re: NSImage batch conversion
Gregory Weston <uce@[E  2007-09-21 11:16:53 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 19:58:31 CDT 2008.