Click here to Skip to main content
15,879,535 members
Articles / Mobile Apps / Windows Mobile

PSD for PocketPC Windows Mobile 2003

Rate me:
Please Sign up or sign in to vote.
4.50/5 (5 votes)
28 Sep 2006CPOL1 min read 25.8K   153   14   1
A generic class to import Adobe's Photoshop (.psd) images under PocketPC Windows Mobile 2003.

Introduction

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.

Using MyPSD::CPSD in your projects

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;.

How to use MyPSD::CPSD

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

Supported formats

The following formats are supported: RGB, Lab, CMY, CMYK, Indexed, Grayscale, Duotone. These formats could be uncompressed or compressed with RLE.

Unsupported formats/Not yet implemented

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).

License

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.

Thanks

I would like to thank image_processor of this forum for fixing a bug I had in the original code.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Greece Greece
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generalconvert psd into jpeg Pin
Member 22893697-Feb-08 17:49
Member 22893697-Feb-08 17:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.