• 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
completely and utterly confused with NSImage + MySQL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

completely and utterly confused with NSImage + MySQL


  • Subject: completely and utterly confused with NSImage + MySQL
  • From: Eric Smith <email@hidden>
  • Date: Fri, 24 Feb 2006 20:36:29 -0800

Check out the following code:

************************************************************************ **********
myImage = [[NSImage alloc] initWithContentsOfFile:@"/Users/esmith/ Software/src/Images/image1.jpg"];

NSArray* theReps = [myImage representations];
NSBitmapImageRep* bitmapRep;
int count = [theReps count];
int i;
id das_image = nil;
for( i = 0; i < count; i++ ){
das_image = [ theReps objectAtIndex: i ];
if( [ das_image isMemberOfClass: [NSBitmapImageRep class ] ] ){
bitmapRep = (NSBitmapImageRep*) das_image;
break;
}
}


NSData* theData = [bitmapRep TIFFRepresentation];

NSString *tempData = [theData description];
NSImage *newImage = [[NSImage alloc] initWithData:[tempData propertyList]];
theSize = [newImage size];


[theImageView setImage:newImage];
************************************************************************ *****


Pretty straightforward. Read an image, create NSData from a representation, then create another image. This works (sort of). If I read an image from a file which is compressed, the image appears small. This happens even if I just drag and drop from the finder into the NSImageView (theImageView).

If I take [tempData cString], run it through mysql_real_escape_string and then read it back into an image, using [[NSImage alloc] initWithData:...], the result is just a *portion* of the original image. How much? It depends on the level of compression. If I save an uncompressed image to the database, it comes back out as an entire image. What is going on here?!! Anyone have any ideas?

Thanks,
Eric
_______________________________________________
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


  • Follow-Ups:
    • Re: completely and utterly confused with NSImage + MySQL
      • From: Andrew Farmer <email@hidden>
  • Prev by Date: ABPeoplePickerView and setNameDoubleAction
  • Next by Date: Re: Mutable/non-mutable bindings in NSTextView
  • Previous by thread: ABPeoplePickerView and setNameDoubleAction
  • Next by thread: Re: completely and utterly confused with NSImage + MySQL
  • Index(es):
    • Date
    • Thread