65.9K
CodeProject 正在变化。 阅读更多。
Home

PocketPC Windows Mobile 2003 的 PSD

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.50/5 (5投票s)

2006 年 9 月 28 日

CPOL

1分钟阅读

viewsIcon

26575

downloadIcon

172

一个用于在 PocketPC Windows Mobile 2003 上导入 Adobe Photoshop (.psd) 图像的通用类。

引言

MyPSD::CPSD 是一个 C++ 类,可以加载以 Adobe Photoshop 原生格式保存的图像。我已经将我的原始代码移植到 PocketPC 平台。

在您的项目中使用 MyPSD::CPSD

要使用该类,只需将两个文件 MyPSD.h/.cpp 包含到您的项目中即可。由于该类位于它自己的命名空间中,因此可以使用完整名称 MyPSD::CPSD psd;,或者首先使用指令 using namespace MyPSD;,然后只需声明一个局部变量 CPSD psd;

如何使用 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

支持的格式

支持以下格式:RGB、Lab、CMY、CMYK、索引色、灰度、双色调。这些格式可以是未压缩的或使用 RLE 压缩的。

不支持的格式/尚未实现

位图(黑白),以及任何使用 ZIP 压缩的格式,无论有预测还是没有预测,这主要是因为我不了解 ZIP 压缩算法(有和没有预测)。

许可证

MyPSD::CPSD 是免费的;但是,如果您要在任何类型的软件中使用它,尤其是商业软件,如果您能给我发邮件,我将不胜感激;很高兴得知您编写的东西被他人使用。

谢谢

我谨向该论坛的 image_processor 感谢他修复了我原始代码中的一个错误。

© . All rights reserved.