예제 #1
0
void MapEditor::OnLevelMapCalc(Level& level, int number)
{
	if (level.GetMapBG().IsEmpty())
	{
		Exclamation(NFormat(t_("Please, select the image for level: %s"), level.GetName()));
		return;
	}

	String fp = AppendFileName( AppendFileName( GetFileDirectory(GetExeFilePath()), "Maps"),
		level.GetMapBG());

	if (!FileExists(fp))
	{
		Exclamation(NFormat(t_("Image file not exist: %s"), fp));
		return;
	}

	String name = level.GetName();
	double zx   = level.GetZoomDX();
	Size   pz   = level.GetPageSize();
	Size   sz   = level.GetCellSize();

	FileIn in(fp);
	One<StreamRaster> r = StreamRaster::OpenAny(in);
	if (!r)
	{
		Exclamation(NFormat(t_("Error while loading image file: %s"), fp));
		return;
	}

	Image img = r->GetImage();
	Calculate(sz.cx, sz.cy, pz.cx, pz.cy, zx,
		NFormat("%s-%d", _map.GetName(), number + 1), img);
}
예제 #2
0
bool RasterPlayer::LoadBuffer(const String &buffer) {
	if (buffer.IsEmpty())
		return false;
	StringStream str(buffer);
	One<StreamRaster> raster = StreamRaster::OpenAny(str);
	if(!raster) 
		return false;
	
	Stop();	
	images.Clear();
	delays.Clear();	
	
	Size sz = raster->GetSize();
	ImageDraw iw(sz); 
	Image previous;
	Rect r;
	for (int i = 0; i < raster->GetPageCount(); ++i) {
		if (previous) {
			iw.Alpha().DrawImage(r, previous, GrayColor(255));
			iw.DrawImage(r, previous);
			previous = Null;
		}
		raster->SeekPage(i);
		r = raster->GetPageRect(i);
		switch (raster->GetPageDisposal(i)) {
		case 1:
		case 2:	iw.DrawRect(r, SColorFace());
				break;
		//case 2: iw.DrawRect(sz, White());	  // It seems gif files do not comply with standard
		//		break;
		case 4:	if (i > 0) 
					previous = GetRect_(images[i-1], r);
				iw.DrawRect(sz, SColorFace()); 
				break;
		}
		iw.Alpha().DrawImage(r.left, r.top, raster->GetImage(0, 0, r.right-r.left, r.bottom-r.top), GrayColor(255));
		iw.DrawImage(r.left, r.top, raster->GetImage(0, 0, r.right-r.left, r.bottom-r.top));
		images.Add(iw);
		delays.Add(max(50, 10*raster->GetPageDelay(i)));
	}
	ind = 0;
	return true;	
}
예제 #3
0
파일: RichImage.cpp 프로젝트: koz4k/soccer
Image RichRawImage::ToImage(const Value& data, Size sz, void *) const
{
	String s = data;
	StringStream ss(s);
	One<StreamRaster> r = StreamRaster::OpenAny(ss);
	if(r) {
		Image x = r->GetImage();
		return Rescale(x, sz);
	}
	return Null;
}
예제 #4
0
파일: RichImage.cpp 프로젝트: koz4k/soccer
void RichRawImage::Paint(const Value& data, Draw& w, Size sz, void *) const
{
	String s = data;
	StringStream ss(s);
	One<StreamRaster> r = StreamRaster::OpenAny(ss);
	if(r) {
		Size isz = r->GetSize();
		if(isz.cx * isz.cy > sz.cx * sz.cy) { // conserve memory by scaling down from source
			ImageEncoder m;
			Rescale(m, sz, *r, r->GetSize());
			w.DrawImage(0, 0, sz.cx, sz.cy, m);
		}
		else
			w.DrawImage(0, 0, sz.cx, sz.cy, r->GetImage()); // scale up by Draw to give e.g. PDF chance to store unscaled
	}
}
예제 #5
0
void ImageMT::LoadImage()
{
	FileSel dlg;
	dlg.Type("Image files","*.bmp *.png *.tif *.jpg");
	dlg.Type("Image: JPEG","*.jpg");
	dlg.Type("Image: Portable Nework Graphics","*.png");
	dlg.Type("Image: Tagged Image Format","*.tif");
	dlg.Type("Image: Windows Bitmap (24bit)","*.bmp");
	dlg.ActiveDir(GetCurrentDirectory());

	if(!dlg.ExecuteOpen("Open Image"))return;

	SetCurrentDirectory(dlg.GetActiveDir());

	String path = ~dlg;

	FileIn in(path);

	if(in.IsError())
	{
		String s = Format("Error opening image file %s",path);
		PromptOK(s);
		return;
	}

	One<StreamRaster> r = StreamRaster::OpenAny(in);

	if(!r)
	{
		String s = Format("Error opening streamraster file %s",path);
		PromptOK(s);
		return;
	}

	Layer* pLayer = new Layer;

	Size sz = GetSize();

	pLayer->m_img = r->GetImage();
	pLayer->m_rc.left = 0;
	pLayer->m_rc.right = 1;
	pLayer->m_rc.top = 0;
	pLayer->m_rc.bottom = 1;

	m_pLayers.Add(pLayer);
}
예제 #6
0
파일: Img.cpp 프로젝트: ultimatepp/mirror
	virtual IdeDesigner *CreateDesigner(const char *path, byte) {
		if(IsImgFile(path)) {
			FileIn in(path);
			One<StreamRaster> o = StreamRaster::OpenAny(in);
			if(o) {
				Size sz = o->GetSize();
				if(ToLower(GetFileExt(path)) == ".png" && sz.cx <= 768 && sz.cy <= 512) {
					IdePngDes *d = new IdePngDes;
					d->Load(path);
					d->RestoreEditPos();
					return d;
				}
				else {
					IdeImgView *d = new IdeImgView;
					d->img_sz = sz;
					d->filename = path;
					if(sz.cx <= 1024 && sz.cy <= 768)
						d->img = o->GetImage();
					else {
						ImageEncoder m;
						Rescale(m, GetFitSize(sz, Size(1024, 768)), *o, sz);
						d->img = m;
					}
					return d;
				}
			}
			else
			if(ToLower(GetFileExt(path)) == ".png" && GetFileLength(path) <= 0) {
				IdePngDes *d = new IdePngDes;
				d->Create(path);
				d->RestoreEditPos();
				return d;
			}
		}
		return NULL;
	}