Esempio n. 1
0
void test_image(VFS* vfs, RenderBackend& renderbackend) {
	renderbackend.init();
	renderbackend.createMainScreen(800, 600, 0, false, "FIFE", "");

	ImageLoader provider(vfs);
	boost::scoped_ptr<Image> img(dynamic_cast<Image*>(provider.loadResource(ImageLocation(IMAGE_FILE))));
	
	int h = img->getHeight();
	int w = img->getWidth();
	for (int i = 0; i < 100; i++) {
		renderbackend.startFrame();
		img->render(Rect(i, i, w, h));
		renderbackend.endFrame();
	}	
	for (int j = 0; j < 5; j++) {
		for (int i = -10; i < 10; i++) {
			renderbackend.startFrame();
			img->setXShift(i);
			img->setYShift(i);
			img->render(Rect(200, 200, w, h));
			renderbackend.endFrame();
		}	
	}
}
Esempio n. 2
0
void test_gui_image(RenderBackend& renderbackend, gcn::Graphics& graphics, ImagePool& pool) {
		boost::scoped_ptr<VFS> vfs(new VFS());
		vfs->addSource(new VFSDirectory(vfs.get()));

		pool.addResourceLoader(new SubImageLoader());
		pool.addResourceLoader(new ImageLoader(vfs.get()));

		GuiImageLoader imageloader(pool);
		gcn::Image::setImageLoader(&imageloader);	


		gcn::Container* top = new gcn::Container();
		top->setDimension(gcn::Rectangle(0, 0, 200, 300));
		gcn::Gui* gui = new gcn::Gui();
		gui->setGraphics(&graphics);
		gui->setTop(top);
		gcn::Label* label = new gcn::Label("Label");

		gcn::Image* guiimage = gcn::Image::load(IMAGE_FILE);
		gcn::Icon* icon = new gcn::Icon(guiimage);
	 
		top->add(label, 10, 10);
		top->add(icon, 10, 30);

		ImageLoader provider(vfs.get());
		boost::scoped_ptr<Image> img(dynamic_cast<Image*>(provider.loadResource(ImageLocation(IMAGE_FILE))));

		int h = img->getHeight();
		int w = img->getWidth();
		for (int i = 0; i < 100; i+=2) {
			renderbackend.startFrame();
			img->render(Rect(i, i, w, h));
			gui->logic();
			gui->draw();
			renderbackend.endFrame();
		}
		delete label;
		delete icon;
		delete guiimage;
	}
Esempio n. 3
0
void test_subimage(VFS* vfs, RenderBackend& renderbackend) {
	renderbackend.init();
	renderbackend.createMainScreen(800, 600, 0, false, "FIFE", "");

	ImageLoader imgprovider(vfs);
	boost::scoped_ptr<Image> img(dynamic_cast<Image*>(imgprovider.loadResource(ImageLocation(SUBIMAGE_FILE))));

	ImageLocation location(SUBIMAGE_FILE);
	location.setParentSource(&*img);
	int W = img->getWidth();
	int w = W / 12;
	int H = img->getHeight();
	int h = H / 12;
	location.setWidth(w);
	location.setHeight(h);
	std::vector<Image*> subimages;

	SubImageLoader subprovider;
	for (int x = 0; x < (W - w); x+=w) {
		for (int y = 0; y < (H - h); y+=h) {
			location.setXShift(x);
			location.setYShift(y);
			Image* sub = dynamic_cast<Image*>(subprovider.loadResource(location));
			subimages.push_back(sub);
		}
	}
	
	for (unsigned int i = 0; i < 200; i++) {
		renderbackend.startFrame();
		subimages[i / 40]->render(Rect(200, 200, w, h));
		renderbackend.endFrame();
	}
	std::vector<Image*>::iterator i = subimages.begin();
	while (i != subimages.end()) {
		delete *i;
		i++;
	}

}