/* * This file is part of the AdvanceSCAN project. * * Copyright (C) 2002 Andrea Mazzoleni * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "portable.h" #include "lib/endianrw.h" #include "lib/mng.h" #include "pngex.h" #include #include using namespace std; void png_compress(shrink_t level, data_ptr& out_ptr, unsigned& out_size, const unsigned char* img_ptr, unsigned img_scanline, unsigned img_pixel, unsigned x, unsigned y, unsigned dx, unsigned dy) { data_ptr fil_ptr; unsigned fil_size; unsigned fil_scanline; data_ptr z_ptr; unsigned z_size; unsigned i; unsigned char* p0; fil_scanline = dx * img_pixel + 1; fil_size = dy * fil_scanline; z_size = oversize_zlib(fil_size); fil_ptr = data_alloc(fil_size); z_ptr = data_alloc(z_size); p0 = fil_ptr; for(i=0;i= 12) { cout << " width:" << be_uint32_read(data + 4) << " height:" << be_uint32_read(data + 8); } if (size >= 20) { cout << " x:" << (int)be_uint32_read(data + 12) << " y:" << (int)be_uint32_read(data + 16); } break; case ADV_MNG_CN_FRAM : if (size >= 1) { cout << " mode:" << (unsigned)data[0]; } if (size > 1) { i = 1; while (i < size && data[i]!=0) ++i; cout << " len:" << i-1; if (size >= i+2) { cout << " delay_mode:" << (unsigned)data[i+1]; } if (size >= i+3) { cout << " timeout:" << (unsigned)data[i+2]; } if (size >= i+4) { cout << " clip:" << (unsigned)data[i+3]; } if (size >= i+5) { cout << " syncid:" << (unsigned)data[i+4]; } if (size >= i+9) { cout << " tick:" << be_uint32_read(data+i+5); } if (size >= i+13) { cout << " timeout:" << be_uint32_read(data+i+9); } if (size >= i+14) { cout << " dt:" << (unsigned)data[i+10]; } if (size >= i+15) { cout << " ..."; } } break; case ADV_MNG_CN_DEFI : cout << " id:" << be_uint16_read(data+0); if (size >= 3) { switch (data[2]) { case 0 : cout << " visible:yes"; break; case 1 : cout << " visible:no"; break; default : cout << " visible:?"; break; } } if (size >= 4) { switch (data[3]) { case 0 : cout << " concrete:abstract"; break; case 1 : cout << " concrete:concrete"; break; default : cout << " concrete:?"; break; } } if (size >= 12) { cout << " x:" << (int)be_uint32_read(data + 4) << " y:" << (int)be_uint32_read(data + 8); } if (size >= 28) { cout << " left:" << be_uint32_read(data + 12) << " right:" << be_uint32_read(data + 16) << " top:" << be_uint32_read(data + 20) << " bottom:" << be_uint32_read(data + 24); } break; case ADV_MNG_CN_MOVE : cout << " id_from:" << be_uint16_read(data+0) << " id_to:" << be_uint16_read(data+2); switch (data[4]) { case 0 : cout << " type:replace"; break; case 1 : cout << " type:add"; break; default : cout << " type:?"; break; } cout << " x:" << (int)be_uint32_read(data + 5) << " y:" << (int)be_uint32_read(data + 9); break; case ADV_MNG_CN_PPLT : switch (data[0]) { case 0 : cout << " type:replacement_rgb"; break; case 1 : cout << " type:delta_rgb"; break; case 2 : cout << " type:replacement_alpha"; break; case 3 : cout << " type:delta_alpha"; break; case 4 : cout << " type:replacement_rgba"; break; case 5 : cout << " type:delta_rgba"; break; default : cout << " type:?"; break; } i = 1; while (i