示例#1
0
文件: vxl_file.cpp 项目: ChangerR/xcc
int Cvxl_file::extract_as_pcx(const Cfname& name, t_file_type ft, const t_palet _palet) const
{
	t_palet palet;
	memcpy(palet, _palet, sizeof(t_palet));
	convert_palet_18_to_24(palet);
	const t_vxl_section_tailer& section_tailer = *get_section_tailer(0);
	const int cx = section_tailer.cx;
	const int cy = section_tailer.cy;
	const int cz = section_tailer.cz;
	Cvirtual_binary s;
	for (int i = 0; i < cz; i++)
	{
		memset(s.write_start(cx * cy), 0, cx * cy);
		int j = 0;
		for (int y = 0; y < cy; y++)
		{
			for (int x = 0; x < cx; x++)
			{
				const byte* r = get_span_data(0, j);
				if (r)
				{
					int z = 0;
					while (z < cz)
					{
						z += *r++;
						int c = *r++;
						while (c--)
						{
							if (i == z)
								s.data_edit()[x + cx * y] = *r;
							r += 2;
							z++;
						}
						r++;
					}
				}
				j++;
			}
		}
		Cfname t = name;
		t.set_title(name.get_ftitle() + " " + nwzl(4, i));
		int error = image_file_write(t, ft, s.data(), palet, cx, cy);
		if (error)
			return error;
	}
	return 0;
}
示例#2
0
int Cwsa_dune2_file::extract_as_pcx(const Cfname& name, const t_palet _palet) const
{
	t_palet palet;
	convert_palet_18_to_24(_palet, palet);
	int error = 0;
	const int cx = get_cx();
	const int cy = get_cy();
	const int c_frames = get_c_frames();
	byte* frame = new byte[cx * cy];
	byte* s = new byte[64 << 10];
	byte* d = new byte[cx * cy * 2];
	memset(frame, 0, cx * cy);
	for (int i = 0; i < c_frames; i++)
	{
		if (get_offset(i))
		{
			decode80(get_frame(i), s);
			decode40(s, frame);
		}
		int cb_d = pcx_encode(frame, d, cx, cy, 1);
		Cpcx_file_write f;
		Cfname t = name;
		t.set_title(name.get_ftitle() + " " + nwzl(4, i));
		error = f.open_write(t);
		if (error)
			break;
		f.set_size(cx, cy, 1);
		error = f.write_header();
		if (!error)
			error = f.write_image(d, cb_d);
		if (!error)
			error = f.write_palet(palet);
		f.close();
		if (error)
			break;
	}
	delete[] d;
	delete[] s;
	delete[] frame;
	return error;
}