Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Loading JPEGs in Cocoa

Loading JPEGs in Cocoa
Thread Tools
Forum Regular
Join Date: Dec 2000
Location: Rehoboth Beach,DE USA
Status: Offline
Reply With Quote
Feb 13, 2001, 04:09 AM
 
I'm writing a very basic screen saver in Cocoa that displays a static image from a file included in the .app bundle.I had originally planned to use TIFFs and NSImage but each image is approx. 2 MBs,even with compression,an unacceptably large file size,so I would like to use JPEGs with a file size of around 100 KBs each but as everyone knows NSImage doesn't support JPEGs.I would like any advice anyone has on how to read a JPEG from a file and display it in a ScreenSaverView.I'm a beginner programmer so feel free to go into as much detail as you would like.
     
Mac Elite
Join Date: Oct 2000
Location: Australia
Status: Offline
Reply With Quote
Feb 13, 2001, 05:59 AM
 
Look at using QuickTime's GraphicImporter component. It can read most popular graphics formats, certainly including JPEG.

QuickTIme will handle everything for you - from loading from a filespec (FileRef under X?) to drawing it into whatever drawing port you give it. With QuickTime, you can get a JPEG onto the screen in about 3 lines of code, even in Classic/Carbon.

I can't help you with calling QT with Cocoa though as I haven't been Cocoaized yet.
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Feb 13, 2001, 03:54 PM
 
It's not in the Public Beta, but apparantly in later builds you can access Carbon controls from within Cocoa, so QT should work :-)
     
Fresh-Faced Recruit
Join Date: Feb 2001
Location: Tokyo, Japan
Status: Offline
Reply With Quote
Feb 13, 2001, 07:07 PM
 
Originally posted by Rick1138:
... but as everyone knows NSImage doesn't support JPEGs.
Actually, NSImage can import not only JPEGs but also PNGs, PDFs, PSDs and such, since it now uses QT codec to read image data. You can view what format NSImage accepts by

NSArray *fileTypes = [NSImage imageFileTypes];

The array fileTypes should contain quite a few image format it can import.
     
Forum Regular
Join Date: Dec 2000
Location: Rehoboth Beach,DE USA
Status: Offline
Reply With Quote
Feb 14, 2001, 12:56 AM
 
tea4u,do you know where I can get any more documentation on NSImage and JPEGs?
     
Fresh-Faced Recruit
Join Date: Feb 2001
Location: Tokyo, Japan
Status: Offline
Reply With Quote
Feb 14, 2001, 04:13 AM
 
Originally posted by Rick1138:
tea4u,do you know where I can get any more documentation on NSImage and JPEGs?
I don't think it's made it in the official documentation yet. Altough I accidentally found it, Cocoa AppKit release note says:

<begin quote>
NSImage via NSBitmapImageRep now uses the QuickTime GraphicsImporter to read additional bitmap image types.
<end quote>

You can find the release note at http://developer.apple.com/techpubs/...es/AppKit.html


[This message has been edited by tea4u (edited 02-14-2001).]
     
Forum Regular
Join Date: Dec 2000
Location: Rehoboth Beach,DE USA
Status: Offline
Reply With Quote
Feb 14, 2001, 06:19 PM
 
Thanks for the info
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:23 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2