Hot File

Import Adobe Photoshop (.psd) images

View: 735    Dowload: 0   Comment: 0   Post by: sonbka04  
Author: none   Category: Adobe Photoshop   Fields: Computers - Technology

0 point/1 review File has been tested

Download   import-adobe-photoshop-psd.rar (628.30 KB)

You need to Sign In to download the file import-adobe-photoshop-psd.rar
If you do not have an account then Sign up for free here

Download error   Report copyright violation

MyPSD::CPSD class is a C++ class that can load images saved in Adobe's Photoshop native format. Due to my new job I had to upgrade to Visual Studio 2005, but still the class is as portable as possible, hence it uses standard C++ and STL. With minor changes, it can be ported to Visual Studio 6 (uses an older version of STL) or even to other Operating Systems.

Introduction

PId_0

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

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

How to make it compatible to Visual Studio 6

The STL that comes with Visual Studio 6 does not support the method push_back for std::string. One way is to use CStrings, but then you will have to use MFC, and the other way is to make some minor changes where strings are used. I.e.:

Collapse | Copy Code
std::string strOSType;
for(unsigned int nChar = 0; nChar < 4; ++nChar)
    strOSType.push_back(image_resource.OSType[nChar]);

std::string strOSType = "";
for(unsigned int nChar = 0; nChar < 4; ++nChar)
    strOSType += image_resource.OSType[nChar];

More info than necessary... future release... maybe

In the MyPsd.h file, I have put more info than is actually used in the demo, as my intention is someday to implement layers as they are supported in Photoshop. The way MyPSD::CPSD class is implemented in the current version, the HBITMAP that someone gets is the merged outcome of all layers. In the future, I will try to have each layer separately detached from the original image, but don't hold your breath as I don't know if I have enough free time to do so.

Supported Formats

RGB, Lab, CMY, CMYK, Indexed, Grayscale, Duotone. These formats could be uncompressed or compressed with RLE.

Unsupported Formats/Not yet implemented

Bitmap (Black & 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).

Import Adobe Photoshop (.psd) images

Import Adobe Photoshop (.psd) images Posted on 24-03-2014  MyPSD::CPSD class is a C++ class that can load images saved in Adobe's Photoshop native format. Due to my new job I had to upgrade to Visual Studio 2005, but still the class is as portable as possible, hence it uses standard C++ and STL. With minor changes, it can be ported to Visual Studio 6 (uses an older version of STL) or even to other Operating Systems. 5/10 735

Comment:

To comment you must be logged in members.

Files with category

 
Newsletter Email

File suggestion for you

File top downloads

logo codetitle
Codetitle.com - library source code to share, download the file to the community
Copyright © 2015. All rights reserved. codetitle.com Develope by Vinagon .Ltd