void processlayers(psd_file_t f, struct psd_header *h) { int i; psd_bytes_t savepos; extern char *last_layer_name; if(listfile) fputs("assetlist = {\n", listfile); for(i = 0; i < h->nlayers; ++i){ struct layer_info *li = &h->linfo[i]; psd_pixels_t cols = li->right - li->left, rows = li->bottom - li->top; VERBOSE("\n layer %d (\"%s\"):\n", i, li->name); if(listfile && cols && rows){ if(numbered) fprintf(listfile, "\t\"%s\" = { pos={%4d,%4d}, size={%4u,%4u} }, -- %s\n", li->nameno, li->left, li->top, cols, rows, li->name); else fprintf(listfile, "\t\"%s\" = { pos={%4d,%4d}, size={%4u,%4u} },\n", li->name, li->left, li->top, cols, rows); } if(xml){ fputs("\t<LAYER NAME='", xml); fputsxml(li->name, xml); // FIXME: what encoding is this in? maybe PDF Latin? fprintf(xml, "' TOP='%d' LEFT='%d' BOTTOM='%d' RIGHT='%d' WIDTH='%u' HEIGHT='%u'>\n", li->top, li->left, li->bottom, li->right, cols, rows); } layerblendmode(f, 2, 1, &li->blend); last_layer_name = NULL; if(extra || unicode_filenames){ // Process 'additional data' (non-image layer data, // such as adjustments, effects, type tool). savepos = ftello(f); fseeko(f, li->additionalpos, SEEK_SET); UNQUIET("Layer %d additional data:\n", i); doadditional(f, h, 2, li->additionallen); fseeko(f, savepos, SEEK_SET); // restore file position } li->unicode_name = last_layer_name; doimage(f, li, unicode_filenames && last_layer_name ? last_layer_name : (numbered ? li->nameno : li->name), h); if(xml) fputs("\t</LAYER>\n\n", xml); } VERBOSE("## end of layer image data @ %ld\n", (long)ftello(f)); }
void processlayers(psd_file_t f, struct psd_header *h) { int i, j = 0, c = 0; //char buf[7]; psd_bytes_t savepos; extern char *last_layer_name; if(listfile) fputs("assetlist = {\n", listfile); for(i = 0; i < h->nlayers; ++i){ struct layer_info *li = &h->linfo[i]; psd_pixels_t cols = li->right - li->left, rows = li->bottom - li->top; VERBOSE("\n layer %d (\"%s\"):\n", i, li->name); if(listfile && cols && rows){ if(numbered) fprintf(listfile, "\t\"%s\" = { pos={%4d,%4d}, size={%4u,%4u} }, -- %s\n", li->nameno, li->left, li->top, cols, rows, li->name); else fprintf(listfile, "\t\"%s\" = { pos={%4d,%4d}, size={%4u,%4u} },\n", li->name, li->left, li->top, cols, rows); } if(xml){ fputs("\t<LAYER NAME='", xml); fputsxml(li->name, xml); // FIXME: what encoding is this in? maybe PDF Latin? fprintf(xml, "' TOP='%d' LEFT='%d' BOTTOM='%d' RIGHT='%d' WIDTH='%u' HEIGHT='%u'>\n", li->top, li->left, li->bottom, li->right, cols, rows); } layerblendmode(f, 2, 1, &li->blend); last_layer_name = NULL; if(extra || unicode_filenames){ // Process 'additional data' (non-image layer data, // such as adjustments, effects, type tool). savepos = (psd_bytes_t)ftello(f); fseeko(f, li->additionalpos, SEEK_SET); g_lid = j; UNQUIET("Layer %d additional data:\n", i); doadditional(f, h, 2, li->additionallen); fseeko(f, savepos, SEEK_SET); // restore file position } li->unicode_name = last_layer_name; if (g_info.layers) { if (li->top || li->left || li->bottom || li->right) { if (!writepng) { if (is_photo(li->name)) { g_info.layers[j].type = LT_Photo; } strcpy(g_info.layers[j].name, li->name); g_info.layers[j].opacity = (float)li->blend.opacity / 255; g_info.layers[j].top = li->top; g_info.layers[j].left = li->left; g_info.layers[j].bottom = li->bottom; g_info.layers[j].right = li->right; g_info.layers[j].channels = li->channels; g_info.layers[j].bound.width = cols; g_info.layers[j].bound.height = rows; g_info.layers[j].center.x = (int)cols / 2 + li->left; g_info.layers[j].center.y = (int)rows / 2 + li->top; #ifdef VER_NO_1_0_0 g_info.layers[j].angle = 0; #else calculate_angle(&g_info.layers[j]); #endif } else { if (li->blend.clipping && j && !h->linfo[i - 1].blend.clipping && LT_Photo == g_info.layers[j].type) { g_info.layers[j - 1].type = LT_Mask; strcpy(g_info.layers[j].mid, g_info.layers[j - 1].lid); } } j++; } } doimage(f, li, unicode_filenames && last_layer_name ? last_layer_name : (numbered ? li->nameno : li->name), h); if(xml) fputs("\t</LAYER>\n\n", xml); } for (i = 0; i < g_info.count; i++) { if (g_info.layers[g_lid].canvas) { c = 1; break; } } if (!c) { g_info.layers[c].canvas = 1; } VERBOSE("## end of layer image data @ %ld\n", (long)ftello(f)); }