Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 3, 2012, 03:46 PM   #1
Samar-
macrumors newbie
 
Join Date: Nov 2012
How to use libjpeg in xCode

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..
Samar- is offline   0 Reply With Quote
Old Nov 3, 2012, 04:21 PM   #2
chown33
macrumors 603
 
Join Date: Aug 2009
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.
chown33 is offline   1 Reply With Quote
Old Nov 3, 2012, 05:03 PM   #3
samdev
macrumors regular
 
Join Date: Sep 2011
Quote:
Originally Posted by Samar- View Post
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.
samdev is offline   1 Reply With Quote
Old Nov 3, 2012, 06:09 PM   #4
PhoneyDeveloper
macrumors 68030
 
PhoneyDeveloper's Avatar
 
Join Date: Sep 2008
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/
PhoneyDeveloper is offline   0 Reply With Quote
Old Nov 3, 2012, 07:13 PM   #5
mfram
macrumors 6502a
 
Join Date: Jan 2010
Location: 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.
mfram is offline   0 Reply With Quote
Old Nov 3, 2012, 11:09 PM   #6
Samar-
Thread Starter
macrumors newbie
 
Join Date: Nov 2012
Quote:
Originally Posted by chown33 View Post
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

----------

Quote:
Originally Posted by samdev View Post
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..

----------

Quote:
Originally Posted by PhoneyDeveloper View Post
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..

----------

Quote:
Originally Posted by mfram View Post
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- is offline   0 Reply With Quote
Old Nov 4, 2012, 07:24 PM   #7
Samar-
Thread Starter
macrumors newbie
 
Join Date: Nov 2012
Quote:
Originally Posted by PhoneyDeveloper View Post
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..
Samar- is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
The App Store app thinks Xcode is installed, but I deleted Xcode. moonman239 Mac Applications and Mac App Store 3 May 6, 2014 05:53 PM
Moving from xcode 3.2 to xcode 4.5.2 compilation error for 'abs' macro in stdlib.h hrishidev Mac Programming 7 Jun 2, 2013 10:36 AM
Xcode 4.5 iNeedAnsurs iPhone 0 Jan 25, 2013 02:49 PM
Xcode 3 vs Xcode 4 when dealing with Objective-C timebourne Mac Programming 8 Sep 23, 2012 05:36 PM
XCode 4.4.1 to Xcode 4.5 in Mountain Lion VinegarTasters OS X 10.8 Mountain Lion 2 Sep 19, 2012 08:55 PM

Forum Jump

All times are GMT -5. The time now is 07:41 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC