69,336
社区成员
发帖
与我相关
我的任务
分享
/* PSD File data structures */
typedef struct
{
guint16 channels; /* Number of channels: 1- 56 */
gboolean transparency; /* Image has merged transparency alpha channel */
guint32 rows; /* Number of rows: 1 - 30000 */
guint32 columns; /* Number of columns: 1 - 30000 */
guint16 bps; /* Bits per channel: 1, 8 or 16 */
guint16 color_mode; /* Image colour mode: {PSDColorMode} */
GimpImageBaseType base_type; /* Image base colour mode: (GIMP) */
guint16 comp_mode; /* Merged image compression mode */
guchar *color_map; /* Colour map data */
guint32 color_map_len; /* Colour map data length */
guint32 color_map_entries; /* Colour map number of entries */
guint32 image_res_start; /* Image resource block start address */
guint32 image_res_len; /* Image resource block length */
guint32 mask_layer_start; /* Mask & layer block start address */
guint32 mask_layer_len; /* Mask & layer block length */
gint16 num_layers; /* Number of layers */
guint32 layer_data_start; /* Layer pixel data start */
guint32 layer_data_len; /* Layer pixel data length */
guint32 merged_image_start; /* Merged image pixel data block start address */
guint32 merged_image_len; /* Merged image pixel data block length */
gboolean no_icc; /* Do not use ICC profile */
guint16 layer_state; /* Active layer number counting from bottom up */
GPtrArray *alpha_names; /* Alpha channel names */
PSDchanneldata **alpha_display_info; /* Alpha channel display info */
guint16 alpha_display_count; /* Number of alpha channel display info recs */
guint32 *alpha_id; /* Alpha channel ids (tattoos) */
guint16 alpha_id_count; /* Number of alpha channel id items */
guint16 quick_mask_id; /* Channel number containing quick mask */
} PSDimage;
#include "config.h"
#include <string.h>
#include <errno.h>
#include <glib/gstdio.h>
#include <libgimp/gimp.h>
#include "psd.h"
#include "psd-util.h"
#include "psd-image-res-load.h"
#include "psd-layer-res-load.h"
#include "psd-load.h"
#include "libgimp/stdplugins-intl.h"
void print_all_psd(FILE *f, struct stat st, PSDimage img_a, PSDlayer **lyr_a,
gint32 image_id, GError *error);
static int save_psdimage_to_file(const char* fileName, char *linefeedp,
PSDimage img_a);
void print_all_psd(FILE *f, struct stat st, PSDimage img_a, PSDlayer **lyr_a,
gint32 image_id, GError *error) {
save_psdimage_to_file("/home/hades/PSDimageValue.properties", "\r\n", img_a);
}
int save_psdimage_to_file(const char* fileName, char *linefeedp, PSDimage img_a) {
FILE *stream;
stream = fopen(fileName, "w");
if (stream == NULL) {
fprintf(stderr, "Cannot open output file.\r\n");
return 1;
}
//guint16 channels; /* Number of channels: 1- 56 */
fprintf(stream, "PSDimage.channels = %d %s", img_a.channels, linefeedp);
printf("PSDimage.channels = %d %s", img_a.channels, linefeedp);
// gboolean transparency; /* Image has merged transparency alpha channel */
fprintf(stream, "PSDimage.transparency(False is 0) = %d %s",
img_a.transparency, linefeedp);
printf("PSDimage.transparency(False is 0) = %d %s", img_a.transparency,
linefeedp);
// guint32 rows; /* Number of rows: 1 - 30000 */
fprintf(stream, "PSDimage.rows(pix) = %d %s", img_a.rows, linefeedp);
printf("PSDimage.rows(pix) = %d %s", img_a.rows, linefeedp);
// guint32 columns; /* Number of columns: 1 - 30000 */
fprintf(stream, "PSDimage.columns(pix) = %d %s", img_a.columns, linefeedp);
printf("PSDimage.columns(pix) = %d %s", img_a.columns, linefeedp);
// guint16 bps; /* Bits per channel: 1, 8 or 16 */
fprintf(stream, "PSDimage.bps = %d %s", img_a.bps, linefeedp);
printf("PSDimage.bps = %d %s", img_a.bps, linefeedp);
// guint16 color_mode; /* Image colour mode: {PSDColorMode} */
fprintf(stream, "PSDimage.color_mode = %d %s", img_a.color_mode, linefeedp);
printf("PSDimage.color_mode = %d %s", img_a.color_mode, linefeedp);
// GimpImageBaseType base_type; /* Image base colour mode: (GIMP) */
fprintf(stream, "PSDimage.base_type = %d %s", img_a.base_type, linefeedp);
printf("PSDimage.base_type = %d %s", img_a.base_type, linefeedp);
// guint16 comp_mode; /* Merged image compression mode */
fprintf(stream, "PSDimage.comp_mode = %d %s", img_a.comp_mode, linefeedp);
printf("PSDimage.comp_mode = %d %s", img_a.comp_mode, linefeedp);
// guchar *color_map; /* Colour map data */
fprintf(stream, "PSDimage.color_map(4ubyte) = 0x%x %s", img_a.color_map,
linefeedp);
printf("PSDimage.color_map(4ubyte) = 0x%x %s", img_a.color_map, linefeedp);
// guint32 color_map_len; /* Colour map data length */
fprintf(stream, "PSDimage.color_map_len = %d %s", img_a.color_map_len,
linefeedp);
printf("PSDimage.color_map_len = %d %s", img_a.color_map_len, linefeedp);
// guint32 color_map_entries; /* Colour map number of entries */
fprintf(stream, "PSDimage.color_map_entries = %d %s",
img_a.color_map_entries, linefeedp);
printf("PSDimage.color_map_entries = %d %s", img_a.color_map_entries,
linefeedp);
// guint32 image_res_start; /* Image resource block start address */
fprintf(stream, "PSDimage.image_res_start = %d %s", img_a.image_res_start,
linefeedp);
printf("PSDimage.image_res_start = %d %s", img_a.image_res_start, linefeedp);
// guint32 image_res_len; /* Image resource block length */
fprintf(stream, "PSDimage.image_res_len = %d %s", img_a.image_res_len,
linefeedp);
printf("PSDimage.image_res_len = %d %s", img_a.image_res_len, linefeedp);
// guint32 mask_layer_start; /* Mask & layer block start address */
fprintf(stream, "PSDimage.mask_layer_start = %d %s",
img_a.mask_layer_start, linefeedp);
printf("PSDimage.mask_layer_start = %d %s", img_a.mask_layer_start,
linefeedp);
// guint32 mask_layer_len; /* Mask & layer block length */
fprintf(stream, "PSDimage.mask_layer_len = %d %s", img_a.mask_layer_len,
linefeedp);
printf("PSDimage.mask_layer_len = %d %s", img_a.mask_layer_len, linefeedp);
// gint16 num_layers; /* Number of layers */
fprintf(stream, "PSDimage.num_layers = %d %s", img_a.num_layers, linefeedp);
printf("PSDimage.num_layers = %d %s", img_a.num_layers, linefeedp);
// guint32 layer_data_start; /* Layer pixel data start */
fprintf(stream, "PSDimage.layer_data_start = %d %s",
img_a.layer_data_start, linefeedp);
printf("PSDimage.layer_data_start = %d %s", img_a.layer_data_start,
linefeedp);
// guint32 layer_data_len; /* Layer pixel data length */
fprintf(stream, "PSDimage.layer_data_len = %d %s", img_a.layer_data_len,
linefeedp);
printf("PSDimage.layer_data_len = %d %s", img_a.layer_data_len, linefeedp);
// guint32 merged_image_start; /* Merged image pixel data block start address */
fprintf(stream, "PSDimage.merged_image_start = %d %s",
img_a.merged_image_start, linefeedp);
printf("PSDimage.merged_image_start = %d %s", img_a.merged_image_start,
linefeedp);
// guint32 merged_image_len; /* Merged image pixel data block length */
fprintf(stream, "PSDimage.merged_image_len = %d %s",
img_a.merged_image_len, linefeedp);
printf("PSDimage.merged_image_len = %d %s", img_a.merged_image_len,
linefeedp);
// gboolean no_icc; /* Do not use ICC profile */
fprintf(stream, "PSDimage.no_icc = %d %s", img_a.no_icc, linefeedp);
printf("PSDimage.no_icc = %d %s", img_a.no_icc, linefeedp);
// guint16 layer_state; /* Active layer number counting from bottom up */
fprintf(stream, "PSDimage.layer_state = %d %s", img_a.layer_state,
linefeedp);
printf("PSDimage.layer_state = %d %s", img_a.layer_state, linefeedp);
// guint16 alpha_display_count; /* Number of alpha channel display info recs */
fprintf(stream, "PSDimage.alpha_display_count = %d %s",
img_a.alpha_display_count, linefeedp);
printf("PSDimage.alpha_display_count = %d %s", img_a.alpha_display_count,
linefeedp);
// guint32 *alpha_id; /* Alpha channel ids (tattoos) */
fprintf(stream, "PSDimage.alpha_id = %d %s", img_a.alpha_id, linefeedp);
printf("PSDimage.alpha_id = %d %s", img_a.alpha_id, linefeedp);
// guint16 alpha_id_count; /* Number of alpha channel id items */
fprintf(stream, "PSDimage.alpha_id_count = %d %s", img_a.alpha_id_count,
linefeedp);
printf("PSDimage.alpha_id_count = %d %s", img_a.alpha_id_count, linefeedp);
// guint16 quick_mask_id; /* Channel number containing quick mask */
fprintf(stream, "PSDimage.quick_mask_id = %d %s", img_a.quick_mask_id,
linefeedp);
printf("PSDimage.quick_mask_id = %d %s", img_a.quick_mask_id, linefeedp);
// GPtrArray *alpha_names; /* Alpha channel names */
// PSDchanneldata **alpha_display_info; /* Alpha channel display info */
return 0;
}