资源简介
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};
评论
共有 条评论