資源簡介
libpsd is used to r/w photoshop file(xxx.psd). It is the Photoshop File Format Encode/Decode Library. It supports for Adobe Photoshop CS4 version, and is compatible with the previous versions of Photoshop.
run-time lib is:MultiThread DLL, debug version. using big-endian mode. programming by ANSI C to belifit porting work.
function list:
1. load/save psd/bmp/jpeg/png file.
2. New psd file, new psd layer.
3. layer direction/brightness/contrast adjust.
4. layer zoom.
5. psd2png.
http://sourceforge.net/projects/slibpsd/
代碼片段和文件信息
#include?
#include?
#include?“bmpfile.h“
#include?“..\\src\\psd_system.h“
#if?0
#define?PIXPLINE??320
int?bmp_read(unsigned?char?*image?int?xsize?int?ysize?char?*filename)?
{
????char?fname_bmp[128];
????FILE?*fp;
????unsigned?char?header[54];
????sprintf(fname_bmp?“%s.bmp“?filename);
????
????if?(!(fp?=?fopen(fname_bmp?“rb“)))?
??????return?-1;
??????
????
????fread(header?sizeof(unsigned?char)?54?fp);
????fread(image?sizeof(unsigned?char)?(size_t)(long)xsize?*?ysize?*?3?fp);
????
????fclose(fp);
????return?0;
}
int?bmp_write(unsigned?char?*image?int?xsize?int?ysize?char?*filename)?
{
????unsigned?char?header[54]?=?{
??????0x42?0x4d?0?0?0?0?0?0?0?0
????????54?0?0?0?40?0?0?0?0?0?0?0?0?0?0?0?1?0?24?0?
????????0?0?0?0?0?0?0?0?0?0?0?0?0?0?0?0?0?0?0?0?
????????0?0?0?0
????};
????long?file_sizewidthheight;
????char?fname_bmp[128];
????FILE?*fp;
????
????file_size?=?(long)xsize?*?(long)ysize?*?3?+?54;
????header[2]?=?(unsigned?char)(file_size?&0x000000ff);
????header[3]?=?(file_size?>>?8)?&?0x000000ff;
????header[4]?=?(file_size?>>?16)?&?0x000000ff;
????header[5]?=?(file_size?>>?24)?&?0x000000ff;
????
????width?=?xsize;
????header[18]?=?width?&?0x000000ff;
????header[19]?=?(width?>>?8)?&0x000000ff;
????header[20]?=?(width?>>?16)?&0x000000ff;
????header[21]?=?(width?>>?24)?&0x000000ff;
????
????height?=?ysize;
????header[22]?=?height?&0x000000ff;
????header[23]?=?(height?>>?8)?&0x000000ff;
????header[24]?=?(height?>>?16)?&0x000000ff;
????header[25]?=?(height?>>?24)?&0x000000ff;
??
????sprintf(fname_bmp?“%s.bmp“?filename);
????
????if?(!(fp?=?fopen(fname_bmp?“wb“)))?
??????return?-1;
??????
????fwrite(header?sizeof(unsigned?char)?54?fp);
????fwrite(image?sizeof(unsigned?char)?(size_t)(long)xsize?*?ysize?*?3?fp);
????
????fclose(fp);
????return?0;
}
void?clonebmp(unsigned?char?*imageint?xsizeint?ysize)
{
????bmp_read(image?xsize?ysize?“orgbmp“);??//orgbmp為當前目錄下的bmp文件名
????bmp_write(image?xsize?ysize?“clone_bmp“);//clone_bmp為克隆的bmp文件名
}
????/**//****************************************************************************
*?名稱:youwritetobmp()
*?功能:寫入bmp文件
*?入口參數:RGBQUAD?*pixarr?----?要寫入的像素數組指針?int?xsize?----?圖像寬度?int?ysize?----?圖像高度?char?*filename?--圖像名稱
*?出口參數:無
*?返回值:-1:錯誤??;0:正確
****************************************************************************/
int?youwritetobmp(RGBQUAD?*pixarr?int?xsize?int?ysize?char?*filename)?{
????unsigned?char?header[54]?=?{
??????0x42?0x4d?0?0?0?0?0?0?0?0
????????54?0?0?0?40?0?0?0?0?0?
????????0?0?0?0?0?0?1?0?24?0?
????????0?0?0?0?0?0?0?0?0?0
????????0?0?0?0?0?0?0?0?0?0?
????????0?0?0?0
????};
????int?i;
????int?j;
????long?widthheight;
????char?fname_bmp[128];
????FILE?*fp;
????long?file_size?=?(long)xsize?*?(long)ysize?*?3?+?54;
????RGBQUAD?zero={000};
評論
共有 條評論