Esempio n. 1
0
int main()
{
	SWFMovie *m;
	SWFShape *shape;
	SWFButton *b;
	SWFDisplayItem *item;
	SWFBlur *blur;
	SWFFilter *f;

	try {
		Ming_init();
		m = new SWFMovie(7);
		shape = new SWFShape();

		shape->setLine(4, 25, 0, 0, 128);
		shape->movePenTo(5, 5);
		shape->drawLineTo( 0, 10);
	
		blur = new SWFBlur(5,5,2);
		f = SWFFilter::BlurFilter(blur);

		b = new SWFButton();
		b->addShape(shape, SWFBUTTON_UP | SWFBUTTON_HIT | SWFBUTTON_OVER | SWFBUTTON_DOWN);
		item = m->add(b);
	
		item->addFilter(f);
		m->save("test01.swf");
	}
	catch (SWFException &e)
	{
		std::cerr << "SWFException: " << e.what() << std::endl << std::endl;
		return EXIT_FAILURE;
	}
	return 0;
}
Esempio n. 2
0
int main()
{
	try {
		SWFDisplayItem *d;
		SWFMovie *m = new SWFMovie();
		SWFButton *b = new SWFButton();
		SWFShape *s = new SWFShape();
		char buf[512];
	
		sprintf(buf, "_root.gotoAndStop(2);");

		s->setLine(2, 255, 0, 0, 255);
		s->drawCircle(20);
	
		b->addCharacter(s, SWFBUTTON_HIT|SWFBUTTON_UP|SWFBUTTON_DOWN|SWFBUTTON_OVER);
	
		b->addAction(new SWFAction(buf), SWFBUTTON_MOUSEUP);	

		d = m->add(b);
		m->add(new SWFAction("_root.stop();"));
		d->moveTo(100, 100);
		m->nextFrame();
	
		d->remove();
		b = new SWFButton();
		sprintf(buf, "_root.gotoAndStop(1);");
		b->addCharacter(s, SWFBUTTON_HIT|SWFBUTTON_UP|SWFBUTTON_DOWN|SWFBUTTON_OVER);
	
		b->addAction(new SWFAction(buf), SWFBUTTON_MOUSEDOWN);
		d = m->add(b);
		d->moveTo(50, 100);

		m->nextFrame();
		m->save("test01.swf");
	}
	catch(SWFException &e)
	{
		std::cerr << "SWFException: " << e.what() << std::endl << std::endl;
		return EXIT_FAILURE;
	}
	return 0;
}
Esempio n. 3
0
int main()
{
	try {
		SWFMovie *m = new SWFMovie(8);
		SWFGradient *g = new SWFGradient();

		g->addEntry(0, 0, 0, 0, 255);	
		g->addEntry(0.2, 0, 10, 0, 255);	
		g->addEntry(0.3, 110, 0, 10, 255);	
		g->addEntry(0.4, 20, 0, 0, 255);	
		g->addEntry(0.5, 0, 20, 0, 255);	
		g->addEntry(0.6, 0, 0, 20, 255);	
		g->addEntry(0.7, 30, 0, 0, 255);

		g->addEntry(0.8, 0, 30, 0, 255);	
		g->addEntry(0.9, 0, 0, 30, 255);		

		SWFFillStyle *fill = SWFFillStyle::GradientFillStyle(g, SWFFILL_LINEAR_GRADIENT);
		SWFShape *shape = new SWFShape();
		shape->useVersion(SWF_SHAPE4);
		shape->setRightFillStyle(fill);
	
		shape->setLine(1, 0,0,0,255);
		shape->drawLine(100, 0);
		shape->drawLine(0, 100);
		shape->drawLine(-100, 0);
		shape->drawLine(0, -100);

		m->add(shape);
		m->save("test04.swf");
	}
	catch (SWFException &e)
	{
		std::cerr << "SWFException: " << e.what() << std::endl << std::endl;
		return EXIT_FAILURE;
	}
	return 0;

}
Esempio n. 4
0
void drvSWF::show_image(const PSImage & imageinfo)
{

	if (outBaseName == "") {
		errf << "images cannot be handled via standard output. Use an output file" << endl;
		return;
	}


	if (imageinfo.isFileImage) {
		// use imageinfo.FileName;
#if 0
		outf << "<image "		// x=\"" << 0 << "\" y=\"" << 0 << "\"" 
			<< " transform=\"matrix("
			<< imageinfo.normalizedImageCurrentMatrix[0] << ' '
			<< /* - */ -imageinfo.normalizedImageCurrentMatrix[1] << ' '
			// doch doch - zumindest bei im.ps 
			// - no longer needed due to normalization in pstoedit.pro
			<< imageinfo.normalizedImageCurrentMatrix[2] << ' '
			<< -imageinfo.normalizedImageCurrentMatrix[3] << ' '
// transfer
			<< imageinfo.normalizedImageCurrentMatrix[4] << ' '
			<< currentDeviceHeight - imageinfo.normalizedImageCurrentMatrix[5]
			<< ")\"" << " width=\"" << imageinfo.
			width << "\"" << " height=\"" << imageinfo.
			height << "\"" << " xlink:href=\"" << imageinfo.FileName << "\"></image>" << endl;

#endif

#if (defined(USE_PNG) && USE_PNG)
		// from 0.3 on ming may support png directly
		SWFBitmap *bm = new SWFBitmap(imageinfo.FileName.value());
#else
		unsigned int len = strlen(imageinfo.FileName.value());
		char *outfile = cppstrdup(imageinfo.FileName.value());
		outfile[len - 3] = 'd';
		outfile[len - 2] = 'b';
		outfile[len - 1] = 'l';
		png2dbl(imageinfo.FileName.value(), outfile);
		SWFBitmap *bm = new SWFBitmap(outfile);
		delete [] outfile;
#endif
		(void) remove(imageinfo.FileName.value());

		SWFShape *s = new SWFShape;
		SWFFill *swffill = s->addBitmapFill(bm, SWFFILL_TILED_BITMAP);
		s->setRightFill(swffill);

		const float h = (float) bm->getHeight();
		const float w = (float) bm->getWidth();
		s->movePen(0.0f, 0.0f);
		s->drawLine(w, 0.0f);
		s->drawLine(0.0f, h);
		s->drawLine(-w, 0.0f);
		s->drawLine(0.0f, -h);

		/// cout << " h:" << bm->getHeight() << " w:" << bm->getWidth() << endl;
		// SWFDisplayItem *d = movie->add(bm);
		s->end();
		SWFDisplayItem *d = movie->add(s);

		const float *CTM = imageinfo.normalizedImageCurrentMatrix;
		float ma = CTM[0];
		float mb = -CTM[1];
		float mc = CTM[2];
		float md = -CTM[3];

		const Point p(CTM[4], CTM[5]);
		float mx = swfx(p);
		float my = swfy(p);


#if 1
		d->move(0.0f, 0.0f);
		SWFDisplayItem_setMatrix(d->item, ma, mb, mc, md, mx, my);
//          d->item->flags |= ITEM_DISPLACED;
//  d->item->flags |= ITEM_TRANSFORMED;

#else
		const Point p(CTM[4], CTM[5]);
		d->move(swfx(p), swfy(p));
		//  d->rotate(30);
		d->scale(ma, -md);
#endif



	} else {

		errf << "unhandled case for image " << endl;
	}

}