Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

artbeat.easy

macrumors newbie
Original poster
Jul 1, 2010
18
0
Hello i have some pic in some format ( jpg/gif/jpeg ) i want convert pic to png format how i can do ?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Open them in preview and save them as a PNG?

On a more serious note since you posted it in Mac Programming: what programming language? What have you already tried? What did Google tell you? Which documents have you already read?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
me need code to convert image in my cocoa project

So, as per the above: What have you already tried? What did Google tell you? Which documents have you already read?

If you are expecting code written to do exactly what you want that you can then copy and paste (steal) then you are much mistaken. I will guide you to the documentation that you need but only if you demonstrate that you have attempted to solve this yourself and are willing to put some effort in yourself.
 

artbeat.easy

macrumors newbie
Original poster
Jul 1, 2010
18
0
So, as per the above: What have you already tried? What did Google tell you? Which documents have you already read?

If you are expecting code written to do exactly what you want that you can then copy and paste (steal) then you are much mistaken. I will guide you to the documentation that you need but only if you demonstrate that you have attempted to solve this yourself and are willing to put some effort in yourself.

Hi, hm i can write on C++/c99 code for convert all image format to png and others, it's simple ), in google more, very more information about png header or other's format ! BUT i want resolve my problem with COCOA coding and use native API's

i try see classes - NSImage/CGImage but i don't see API's some like - convert/createImageWithFormat and other's for resolve my problem ! all that I have found
- CGImageSourceCreateWithURL
- CGImageCreateWithPNGDataProvider
CGImageCreateWithPNGDataProvider return image, but i don not understand, this api's return NEW image formated PNG ? or this api create image from png image ? anyway i don't see api's some like - writeImageToFile/(NSdata*)getData/ or etc for write new image to file (((

you can help me ?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
You need to look at NSBitmapImageRep, particularly the representationUsingType:properties:.

Cocoas imaging classes are a little more complex that it first appears. Every NSImage has one or more NSImageReps that represent the image in a specific format. As you are only dealing with bitmap types you can be pretty sure than the rep created when you load the image will be a NSBitmapImageRep. If you were less sure (say you wanted a PNG of a PDF) then you would create an NSImage with no data of the correct size, add an NSBitmapImageRep to it (which you create), lock focus on it, draw the image that you want into that context and unlock the focus. You now have a NSBitmapImageRep with the contents you want to use the method I linked to above.
 

artbeat.easy

macrumors newbie
Original poster
Jul 1, 2010
18
0
You need to look at NSBitmapImageRep, particularly the representationUsingType:properties:.

Cocoas imaging classes are a little more complex that it first appears. Every NSImage has one or more NSImageReps that represent the image in a specific format. As you are only dealing with bitmap types you can be pretty sure than the rep created when you load the image will be a NSBitmapImageRep. If you were less sure (say you wanted a PNG of a PDF) then you would create an NSImage with no data of the correct size, add an NSBitmapImageRep to it (which you create), lock focus on it, draw the image that you want into that context and unlock the focus. You now have a NSBitmapImageRep with the contents you want to use the method I linked to above.

fnks )))
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.