René Nyffenegger's collection of things on the web | |
René Nyffenegger on Oracle - Most wanted - Feedback
- Follow @renenyffenegger
|
Clipping bitmaps [Ming wrapper example] | ||
This example demonstrates how a bitmap can be clipped (alson known as masking) and then displayed.
The originial jpg (Ente.jpg) is not clipped. The clipping circle comes through the call of
shape.Circle .
Note, althought the class is called Bitmap, it handles jpg's perfectly well.
This flash movie was created with the following program. ClipBmp.cpp
#include "SWFMovie.h" #include "Bitmap.h" int main() { Bitmap jpg("Ente.jpg"); int jpg_width = jpg.Width (); int jpg_height = jpg.Height(); int jpg_smaller_dim = jpg_width < jpg_height ? jpg_width : jpg_height; Shape shape; shape.Fill(jpg, SWFFILL_TILED_BITMAP); shape.MoveTo(jpg_width/2,jpg_height/2); shape.Circle(jpg_smaller_dim/2); Movie movie ("ClipBmp.swf", jpg_width, jpg_height, 1, 6); DisplayItem iShape = movie.Add(shape); //iShape.ScaleTo((float)jpg_width/jpg_smaller_dim, (float)jpg_height/jpg_smaller_dim); movie.NextFrame(); movie.Stop(); return 0; } This is one of a series of examples that demonstrates the C++ ming wrapper classes. Other examples can be found here.
|