Click here to Skip to main content
6,596,602 members and growing! (20,675 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Mobile Development » Graphics and Multimedia     Intermediate License: The Code Project Open License (CPOL)

PSD for PocketPC Windows Mobile 2003

By ihaml

A 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
Posted:28 Sep 2006
Views:13,069
Bookmarked:11 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
5 votes for this article.
Popularity: 3.15 Rating: 4.50 out of 5

1

2

3
1 vote, 20.0%
4
4 votes, 80.0%
5

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)

About the Author

ihaml


Member

Occupation: Software Developer
Location: Greece Greece

Other popular Mobile Development articles:

  • Writing Your Own GPS Applications: Part 2
    In part two of the series, the author of "GPS.NET" teaches developers how to write GPS applications suitable for the real world by mastering GPS precision concepts. Source code includes a working NMEA interpreter and sample high-precision application in C# and VB.NET.
  • Writing Your Own GPS Applications: Part I
    What is it that GPS applications need to be good enough to use for in-car navigation? Also, how does the process of interpreting GPS data actually work? In this three-part series, I will cover both topics and give you the skills you need to write a commercial-grade GPS application.
  • Learn How to Find GPS Location on Any SmartPhone, and Then Make it Relevant
    A step by step tutorial for getting GPS from any SmartPhone, even without GPS built in, and then making location useful.
  • iPhone UI in Windows Mobile
    It's an interface that works with transparency effects. As a sample I used an interface just like the iPhone one. In this tutorial I am explaining how simple is working with transparency on Windows Mobile.
  • Pocket 1945 - A C# .NET CF Shooter
    An article on Pocket PC game development
Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 1 of 1 (Total in Forum: 1) (Refresh)FirstPrevNext
Generalconvert psd into jpeg PinmemberMember 228936918:49 7 Feb '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 28 Sep 2006
Editor: Smitha Vijayan
Copyright 2006 by ihaml
Everything else Copyright © CodeProject, 1999-2009
Web10 | Advertise on the Code Project