Recently, I am working on a graphic image project. I don't know why the manager chose the C # language, but I still need to do it.
During this period, a difficult problem occurs as follows:
Delete the specified area of the current layer to display the image of the following layer in this area, which is equivalent to the effect of the PS mask layer.
The implementation code is as follows:
Bitmap tmp = new Bitmap (page. imageFileName); Bitmap image = new Bitmap (tmp. width, tmp. height); Graphics g = Graphics. fromImage (image); g. clear (Color. transparent); g. drawImage (tmp, 0, 0, tmp. width, tmp. height); tmp. dispose (); g = Graphics. fromImage (image); foreach (IVObject obj in page. layers [1]. VObjects) {Matrix m; GraphicsPath path = new GraphicsPath (); switch (obj. getType (). name) {case "RectangleVObject": path. clearMarkers (); path. addRectangle (obj. getVObjectBounds (); m = obj. transform; m. translate (m. offsetX * 1.33F-m. offsetX), (m. offsetY * 1.33F-m. offsetY), MatrixOrder. append); m. scale (1.33F, 1.33F); path. transform (m); g. setClip (path); g. clear (Color. transparent );
Bitmap sourceImage = new Bitmap (imageFileName );
Bitmap image = new Bitmap (sourceImage. Width, sourceImage. Height );
Graphics g = Graphics. FromImage (image );
G. Clear (Color. Transparent );
G. DrawImage (sourceImage, 0, 0, sourceImage. Width, sourceImage. Height );
SourceImage. Dispose ();
GraphicsPath path = new GraphicsPath ();
Rectangle r = new Rectangle (x, y, w, h );
Path. AddRectangle (r );
G. SetClip (path );
G. Clear (Color. Transparent );