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

Samar-

macrumors newbie
Original poster
Nov 3, 2012
4
0
I'm developing an iPhone application and I'm kind of new to everything. I'm working on Mountain Lion OS X 10.8 and using xCode v4.5. I need JPEG handling capabilities in my project and I want to use the libjpeg (http://www.ijg.org/) library. I have tried a few different approaches, but being a bit naive, I'm not really sure how to begin. After downloading packages I've made usual ./configure; make and make install. Right now I have (jconfig.h, jerror.h, jmorecfg.h, jpeglib.h) under (/usr/local/include) and (libjpeg.a, libjpeg.la) under (/usr/local/lib) but I have no idea how to link/use this in my xCode project.
Can anyone link me to a tutorial or give me a push in the right direction?
If anyone successfully installed and used jpeg library please help..
 

chown33

Moderator
Staff member
Aug 9, 2009
10,706
8,346
A sea of green
iOS can do various things with JPEG images without adding any libraries.

"JPEG handling capabilities" is too vague. Please describe what you want to accomplish using libjpeg, that can't be accomplished with existing iOS capabilities. If you don't know, then you should study UIImage and the underlying image-file handling, so you know what's possible without libjpeg.


Your question is basically an XY problem:
http://www.perlmonks.org/index.pl?node_id=542341
.. You want to do X, and you think Y is the best way of doing it.
.. Instead of asking about X, you ask about Y.
 

samdev

macrumors regular
Sep 16, 2011
126
0
I'm developing an iPhone application and I'm kind of new to everything. I'm working on Mountain Lion OS X 10.8 and using xCode v4.5. I need JPEG handling capabilities in my project and I want to use the libjpeg (http://www.ijg.org/) library. I have tried a few different approaches, but being a bit naive, I'm not really sure how to begin. After downloading packages I've made usual ./configure; make and make install. Right now I have (jconfig.h, jerror.h, jmorecfg.h, jpeglib.h) under (/usr/local/include) and (libjpeg.a, libjpeg.la) under (/usr/local/lib) but I have no idea how to link/use this in my xCode project.
Can anyone link me to a tutorial or give me a push in the right direction?
If anyone successfully installed and used jpeg library please help..

The UIImage class already supports these formats:

Code:
Tagged Image File Format (TIFF)		.tiff, .tif
Joint Photographic Experts Group (JPEG)	.jpg, .jpeg
Graphic Interchange Format (GIF)	.gif
Portable Network Graphic (PNG)		.png
Windows Bitmap Format (DIB)		.bmp, .BMPf
Windows Icon Format 			.ico
Windows Cursor				.cur
XWindow bitmap				.xbm

But, unless your JPGs are like camera pictures/photographs, I would avoid using them.
I recommend using PNG instead, because iOS does a crap job of loading JPGs, especially for Retina displays.
You get a lot of banding. JPGs are lossy, and quality is lost when loading them.

Special warning:
Do not use JPG for GUI elements. Your app will look like crap under Retina. Always use PNG.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Using an open source library like libjpeg can be straightforward. Usually the hard part is building the library but you seem to have already done that. make install probably isn't useful. You're not interested in installing into /usr.

Make two folders in your project folder, one for the .a file and the other for the headers. Add the header folder to your project. Add the .a file to your project in the frameworks group. If you've built your library correctly that should be all that's required to use it.

This also might be informative:

http://www.imagemagick.org/download/iOS/
 

mfram

Contributor
Jan 23, 2010
1,304
341
San Diego, CA USA
If this is for an iPhone project, then compiling it for your Mac doesn't help. It will have to be compiled for ARM to work on the iPhone.
 

Samar-

macrumors newbie
Original poster
Nov 3, 2012
4
0
iOS can do various things with JPEG images without adding any libraries.

"JPEG handling capabilities" is too vague. Please describe what you want to accomplish using libjpeg, that can't be accomplished with existing iOS capabilities. If you don't know, then you should study UIImage and the underlying image-file handling, so you know what's possible without libjpeg.


Your question is basically an XY problem:
http://www.perlmonks.org/index.pl?node_id=542341
.. You want to do X, and you think Y is the best way of doing it.
.. Instead of asking about X, you ask about Y.

I'm developing a steganography app and my ultimate goal is to be able to manipulate the DCT coefficients of jpeg images. I now that I access the DCT coefficients in libjpeg using the jpeg_read_coefficients function but I'm not sure if that is possible with UIImage. Hope this clears my problem

----------

The UIImage class already supports these formats:

Code:
Tagged Image File Format (TIFF)		.tiff, .tif
Joint Photographic Experts Group (JPEG)	.jpg, .jpeg
Graphic Interchange Format (GIF)	.gif
Portable Network Graphic (PNG)		.png
Windows Bitmap Format (DIB)		.bmp, .BMPf
Windows Icon Format 			.ico
Windows Cursor				.cur
XWindow bitmap				.xbm

But, unless your JPGs are like camera pictures/photographs, I would avoid using them.
I recommend using PNG instead, because iOS does a crap job of loading JPGs, especially for Retina displays.
You get a lot of banding. JPGs are lossy, and quality is lost when loading them.

Special warning:
Do not use JPG for GUI elements. Your app will look like crap under Retina. Always use PNG.

As I said my ultimate goal is to manipulate the DCT coefficient of a JPEG image to hide some data. I didn't consider other image formats because I want the user to directly choose his/her cover image from the phone library or to take a new one with the camera and both would be JPEG. I guess I might consider converting the image format from JPEG to something simpler. I'll see how it goes.
Thanks for your reply..

----------

Using an open source library like libjpeg can be straightforward. Usually the hard part is building the library but you seem to have already done that. make install probably isn't useful. You're not interested in installing into /usr.

Make two folders in your project folder, one for the .a file and the other for the headers. Add the header folder to your project. Add the .a file to your project in the frameworks group. If you've built your library correctly that should be all that's required to use it.

This also might be informative:

http://www.imagemagick.org/download/iOS/

That looks helpful, thanks..

----------

If this is for an iPhone project, then compiling it for your Mac doesn't help. It will have to be compiled for ARM to work on the iPhone.

Can you please explain how I can compile for ARM so it work on the iPhone? and would it work on the simulator or it has to be a real device?
 

Samar-

macrumors newbie
Original poster
Nov 3, 2012
4
0
Using an open source library like libjpeg can be straightforward. Usually the hard part is building the library but you seem to have already done that. make install probably isn't useful. You're not interested in installing into /usr.

Make two folders in your project folder, one for the .a file and the other for the headers. Add the header folder to your project. Add the .a file to your project in the frameworks group. If you've built your library correctly that should be all that's required to use it.

This also might be informative:

http://www.imagemagick.org/download/iOS/

I tried copying the headers and the .a file into my project but I'm getting the following warning:
ld: warning: ignoring file /Users/.../libjpeg.a, file was built for archive which is not the architecture being linked (i386)
I guess I didn't build the library correctly. Do you know how I can build it to work with the iPhone and the simulator?
I appreciate your help..
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.