Re: TXT Records with NSImages
Re: TXT Records with NSImages
- Subject: Re: TXT Records with NSImages
- From: Michael Ash <email@hidden>
- Date: Fri, 13 Mar 2009 09:59:29 -0400
On Fri, Mar 13, 2009 at 8:45 AM, Joe Turner <email@hidden> wrote:
> Here:
>
> NSImage *original = [NSImage imageNamed:NSImageNameComputer];
> [original setSize:NSMakeSize(10.0f, 10.0f)];
> NSData *image = [original TIFFRepresentation];
> NSBitmapImageRep *imageRep = [NSBitmapImageRep
> imageRepWithData:image];
> NSData *finalData = [imageRep
> representationUsingType:NSPNGFileType properties:nil];
> NSDictionary *txtRecord = [NSDictionary
> dictionaryWithObject:finalData forKey:@"image"];
> NSData *data = [NSNetService
> dataFromTXTRecordDictionary:txtRecord];
> if (data)
> NSLog(@"Data is not nil!");
> [netService setTXTRecordData:data];
That all looks fine (except for the manipulation of the "original"
image, which could be a shared object; make a copy, manipulate that)
but I just remembered something from the Zeroconf spec:
"The format of each constituent string within the DNS TXT record is a
single length byte, followed by 0-255 bytes of text data."
In other words, the total length of each TXT record entry, counting
the key, the value, and the equals sign that separates them, cannot
exceed 255 bytes.
You'll either have to *really* shrink your picture, or find another
way to transmit it.
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden