![]() |
Platforms, Frameworks & Libraries »
Mobile Development »
Graphics and Multimedia
Intermediate
License: The Code Project Open License (CPOL)
PSD for PocketPC Windows Mobile 2003By ihamlA generic class to import Adobe's Photoshop (.psd) images under PocketPC Windows Mobile 2003. |
VC6, VC7, VC7.1, VC8.0, Windows, Win Mobile, MFC, GDI, VS2005, Dev
|
|
Advanced Search |
|
|
|
||||||||||||||||
MyPSD::CPSD is a C++ class that can load images saved in Adobe's Photoshop native format. I have ported my original code to work under the PocketPC platform.
To use the class, just include in your project the two files, MyPSD.h/.cpp. Since the class is placed inside its own namespace, either use the full name, MyPSD::CPSD psd;, or first the directive, using namespace MyPSD; and then just declare a local variable CPSD psd;.
MyPSD::CPSD psd; int nErrorCode = psd.Load("c:\\image.psd"); if ( 0 == nErrorCode ) // No errors were found { int nDPI_x, nDPI_y; // for Horizontal & Vertical dpi int nWidth, nHeight; // for Width & Height in pixels psd.Dimensions(nWidth, nHeight); psd.DPI(nDPI_x, nDPI_y); HBITMAP hBitmap = psd.Detach(); } else if ( -1 == nErrorCode ) // Cannot open file ; // Do something else if ( -2 == nErrorCode ) // Error in the header of the file ; // Do something else if ( -3 == nErrorCode ) // Error in ColourMode Data, i.e. Palette ; // Do something // File must be Index to have ColourMode Data else if ( -4 == nErrorCode ) // Error in ImageResource section of the file ; // Do something else if ( -5 == nErrorCode ) // Error in Mask Info section of the file ; // Do something else if ( -6 == nErrorCode ) // Error in Image Data section of the file ; // Do something // Actual data for pixels else if ( -7 == nErrorCode ) // Image is Black & White ; // Do something // not yet implemented else if ( -8 == nErrorCode ) // An unsupported file format encountered ; // Do something else if ( -9 == nErrorCode ) // Cannot create HBITMAP handle ; // Do something else if ( -10 == nErrorCode ) // Data are compressed ; // Do something // Zip format without prediction. Not yet // implemented else if ( -11 == nErrorCode ) // Data are compressed ; // Do something // Zip format with prediction. Not yet // implemented else if ( -12 == nErrorCode ) // Data are in an unknown format ; // Do something
The following formats are supported: RGB, Lab, CMY, CMYK, Indexed, Grayscale, Duotone. These formats could be uncompressed or compressed with RLE.
Bitmap (Black and White), and any format that is compressed with ZIP with prediction and without prediction, and that is basically because I don't know the ZIP compression algorithm (with and without prediction).
The class MyPSD::CPSD is free; but if you are to use it in any kind of software, especially commercial ones, I would appreciate if you could just email me; it's nice to learn that something you've written is used by others.
I would like to thank image_processor of this forum for fixing a bug I had in the original code.
| You must Sign In to use this message board. | ||||||||
|
||||||||
|
||||||||
|
||||||||
|
||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 28 Sep 2006 Editor: Smitha Vijayan |
Copyright 2006 by ihaml Everything else Copyright © CodeProject, 1999-2009 Web17 | Advertise on the Code Project |