Пример #1
0
void IconDes::Undo()
{
	if(!IsCurrent())
		return;
	Slot& c = Current();
	Vector<Image> undo = UnpackImlData(c.undo);
	if(undo.GetCount() == 0)
		return;
	Vector<Image> redo = UnpackImlData(c.redo);
	redo.Add(c.image);
	c.image = undo.Pop();
	c.supersampling = sRemoveSsFlag(c.image);
	c.undo = PackImlData(undo);
	c.redo = PackImlData(redo);
	SyncImage();
	SetBar();
}
Пример #2
0
void IconDes::SaveUndo()
{
	if(!IsCurrent())
		return;
	Slot& c = Current();
	Vector<Image> undo = UnpackImlData(c.undo);
	int maxn = minmax((single_mode ? 4000000 : 400000) / max(c.image.GetLength(), 1), 4, 128);
	while(undo.GetCount() > maxn)
		undo.Remove(0);
	if(undo.GetCount() && undo.Top() == c.image)
		return;
	sSetSsFlag(c.image, c.supersampling);
	undo.Add(c.image);
	c.undo = PackImlData(undo);
	c.redo.Clear();
	SetBar();
	undo.Clear();
	sRemoveSsFlag(c.image);
}
Пример #3
0
String SaveIml(const Array<ImlImage>& iml, int format) {
	StringStream out;
	if(format == 1) {
		for(int i = 0; i < iml.GetCount(); i++) {
			const ImlImage& c = iml[i];
			if(c.exp)
				out << "IMAGE_META(\"exp\", \"\")\r\n";
			String name = c.name;
			Image buffer = c.image;
			if(IsNull(name))
				name = "im__" + IntStr(i);
			out.PutLine(NFormat("IMAGE_BEGIN(%s)", name));
			int last = 0;
			for(int i = 0; i < buffer.GetHeight(); i++) {
				String scan = PackRLE(buffer[i], buffer.GetWidth());
				if(!scan.IsEmpty() || i == 0) // force at least 1 scan
				{
					for(; last < i; last++)
						out.PutLine("\tIMAGE_SCAN(\"\")");
					out.Put("\tIMAGE_SCAN(");
					PutOctalString(out, scan.Begin(), scan.End(), true);
					out.Put(")\r\n");
					last = i + 1;
				}
			}
			out.Put("IMAGE_PACKED(");
			out.Put(name);
			out.Put(", ");
			StringStream datastrm;
			Size size = buffer.GetSize();
			Point hotspot = buffer.GetHotSpot();
			int encoding = AlphaImageInfo::COLOR_RLE;
			int version = 1;
			datastrm / version;
			datastrm % size % hotspot % encoding;
			ASSERT(!datastrm.IsError());
			String s = datastrm.GetResult();
			PutOctalString(out, s.Begin(), s.End());
			out.Put(")\r\n");
		}
	}
	else {
		out << "PREMULTIPLIED\r\n";
		for(int i = 0; i < iml.GetCount(); i++) {
			const ImlImage& c = iml[i];
			out << "IMAGE_ID(" << c.name << ")";
			if(c.exp)
				out << " IMAGE_META(\"exp\", \"\")\r\n";
			out << "\r\n";
		}
		int ii = 0;
		while(ii < iml.GetCount()) {
			int bl = 0;
			int bn = 0;
			Vector<Image> bimg;
			while(bl < 4096 && ii < iml.GetCount()) {
				const ImlImage& c = iml[ii++];
				bimg.Add(c.image);
				bl += c.image.GetLength();
				bn++;
			}
			String bs = PackImlData(bimg);
			out << "\r\nIMAGE_BEGIN_DATA\r\n";
			bs.Cat(0, ((bs.GetCount() + 31) & ~31) - bs.GetCount());
			const byte *s = bs;
			for(int n = bs.GetCount() / 32; n--;) {
				out << "IMAGE_DATA(";
				for(int j = 0; j < 32; j++) {
					if(j) out << ',';
					out << (int)*s++;
				}
				out << ")\r\n";
			}
			out << "IMAGE_END_DATA(" << bs.GetCount() << ", " << bn << ")\r\n";
		}
	}
	return out.GetResult();
}