 |
 |
Loading JPEGs in Cocoa
|
 |
|
 |
|
Forum Regular
Join Date: Dec 2000
Location: Rehoboth Beach,DE USA
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
|
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|