Re: Cocoa-dev Digest, Vol 16, Issue 1
Re: Cocoa-dev Digest, Vol 16, Issue 1
- Subject: Re: Cocoa-dev Digest, Vol 16, Issue 1
- From: Bruce Stephens <email@hidden>
- Date: Wed, 16 Jan 2019 10:37:23 +1100
Thanks. Appreciated.
> On 16 Jan 2019, at 9:43 am, Vince DeMarco <email@hidden> wrote:
>
> Here is code that will write it out as a PNG
>
> void WriteImageToPath(CGImageRef image,const char *path)
> {
> CGImageDestinationRef dest;
> CFURLRef url;
>
> url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,(const
> UInt8 *)path,strlen(path),0);
> dest = CGImageDestinationCreateWithURL(url,CFSTR("public.png"), 1, NULL);
>
> CGImageDestinationAddImage(dest,image,NULL);
> CGImageDestinationFinalize(dest);
> CFRelease(url);
> CFRelease(dest);
> }
>
> To write it out a a jpeg change the UTI type above from public.png ->
> public.jpeg
>
>
> Its all and there should be examples.
>
> Vince
>
>
>> On Jan 15, 2019, at 2:35 PM, Bruce Stephens <email@hidden> wrote:
>>
>> Any chance to see those few lines of code for NSimage ImageIO to jpeg?
>> Thanks. Bruce.
>>
>>> On 16 Jan 2019, at 7:00 am, email@hidden wrote:
>>>
>>> Send Cocoa-dev mailing list submissions to
>>> email@hidden
>>>
>>> To subscribe or unsubscribe via the World Wide Web, visit
>>> https://lists.apple.com/mailman/listinfo/cocoa-dev
>>> or, via email, send a message with subject or body 'help' to
>>> email@hidden
>>>
>>> You can reach the person managing the list at
>>> email@hidden
>>>
>>> When replying, please edit your Subject line so it is more specific
>>> than "Re: Contents of Cocoa-dev digest..."
>>>
>>>
>>> Today's Topics:
>>>
>>> 1. NSImage to JPEG file? (Carl Hoefs)
>>> 2. Re: NSImage to JPEG file? (Vince DeMarco)
>>> 3. Re: NSImage to JPEG file? (Carl Hoefs)
>>> 4. Re: NSImage to JPEG file? (Alex Zavatone)
>>>
>>>
>>> ----------------------------------------------------------------------
>>>
>>> Message: 1
>>> Date: Mon, 14 Jan 2019 13:17:41 -0700
>>> From: Carl Hoefs <email@hidden>
>>> To: Cocoa Developers <email@hidden>
>>> Subject: NSImage to JPEG file?
>>> Message-ID:
>>> <email@hidden>
>>> Content-Type: text/plain; CHARSET=US-ASCII
>>>
>>> I have a background macOS daemon process (aka Foundation-based "command
>>> line tool") that needs to write out a JPEG file to local disk. The image
>>> resides in an NSImage object (or alternatively, an NSData of raw RGB image
>>> data).
>>>
>>> Short of resorting to something like libjpeg, what is the ObjC way to do
>>> this?
>>>
>>> -Carl
>>>
>>>
>>>
>>> ------------------------------
>>>
>>> Message: 2
>>> Date: Mon, 14 Jan 2019 12:26:08 -0800
>>> From: Vince DeMarco <email@hidden>
>>> To: Carl Hoefs <email@hidden>
>>> Cc: Cocoa Developers <email@hidden>
>>> Subject: Re: NSImage to JPEG file?
>>> Message-ID: <email@hidden>
>>> Content-Type: text/plain; CHARSET=US-ASCII
>>>
>>> Use ImageIO.
>>>
>>> create a CGImageDestinationRef and add the CGImage to it.
>>>
>>> Vince
>>>
>>>
>>>
>>>> On Jan 14, 2019, at 12:17 PM, Carl Hoefs <email@hidden>
>>>> wrote:
>>>>
>>>> I have a background macOS daemon process (aka Foundation-based "command
>>>> line tool") that needs to write out a JPEG file to local disk. The image
>>>> resides in an NSImage object (or alternatively, an NSData of raw RGB image
>>>> data).
>>>>
>>>> Short of resorting to something like libjpeg, what is the ObjC way to do
>>>> this?
>>>>
>>>> -Carl
>>>>
>>>> _______________________________________________
>>>>
>>>> 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
>>>
>>>
>>>
>>> ------------------------------
>>>
>>> Message: 3
>>> Date: Mon, 14 Jan 2019 14:48:15 -0700
>>> From: Carl Hoefs <email@hidden>
>>> To: Vince DeMarco <email@hidden>
>>> Cc: Cocoa Developers <email@hidden>
>>> Subject: Re: NSImage to JPEG file?
>>> Message-ID:
>>> <email@hidden>
>>> Content-Type: text/plain; CHARSET=US-ASCII
>>>
>>> Got it working!
>>> Thanks, that's the tip I needed.
>>> -Carl
>>>
>>>
>>>> On Jan 14, 2019, at 1:26 PM, Vince DeMarco <email@hidden> wrote:
>>>>
>>>> Use ImageIO.
>>>>
>>>> create a CGImageDestinationRef and add the CGImage to it.
>>>>
>>>> Vince
>>>>
>>>>
>>>>
>>>>> On Jan 14, 2019, at 12:17 PM, Carl Hoefs <email@hidden>
>>>>> wrote:
>>>>>
>>>>> I have a background macOS daemon process (aka Foundation-based "command
>>>>> line tool") that needs to write out a JPEG file to local disk. The image
>>>>> resides in an NSImage object (or alternatively, an NSData of raw RGB
>>>>> image data).
>>>>>
>>>>> Short of resorting to something like libjpeg, what is the ObjC way to do
>>>>> this?
>>>>>
>>>>> -Carl
>>>>>
>>>>> _______________________________________________
>>>>>
>>>>> 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
>>>>
>>>
>>>
>>>
>>> ------------------------------
>>>
>>> Message: 4
>>> Date: Mon, 14 Jan 2019 16:06:54 -0600
>>> From: Alex Zavatone <email@hidden>
>>> To: Carl Hoefs <email@hidden>
>>> Cc: Cocoa Developers <email@hidden>
>>> Subject: Re: NSImage to JPEG file?
>>> Message-ID: <email@hidden>
>>> Content-Type: text/plain; CHARSET=US-ASCII
>>>
>>> I will send you something.
>>>
>>> Sent from my iPhone
>>>
>>>> On Jan 14, 2019, at 2:17 PM, Carl Hoefs <email@hidden>
>>>> wrote:
>>>>
>>>> I have a background macOS daemon process (aka Foundation-based "command
>>>> line tool") that needs to write out a JPEG file to local disk. The image
>>>> resides in an NSImage object (or alternatively, an NSData of raw RGB image
>>>> data).
>>>>
>>>> Short of resorting to something like libjpeg, what is the ObjC way to do
>>>> this?
>>>>
>>>> -Carl
>>>>
>>>> _______________________________________________
>>>>
>>>> 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
>>>
>>>
>>>
>>> ------------------------------
>>>
>>> Subject: Digest Footer
>>>
>>> _______________________________________________
>>>
>>> Cocoa-dev mailing list (email@hidden)
>>>
>>> Do not post admin requests or moderator comments to the list.
>>> Contact the moderators at cocoa-dev-admins (at) lists.apple.com
>>>
>>> https://lists.apple.com/mailman/listinfo/cocoa-dev
>>>
>>>
>>> ------------------------------
>>>
>>> End of Cocoa-dev Digest, Vol 16, Issue 1
>>> ****************************************
>> _______________________________________________
>>
>> 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
>
_______________________________________________
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