C # drawing the effect of the handbag and the effect of the disc

Source: Internet
Author: User

Recently, C # has been used to plot the effect of the handbag and the effect of the disc:
(1)

Code:
Bagpackageeffect BPE = new bagpackageeffect ();
BPE. isusesamephoto = false;
BPE. userphotofilename = @ "D:/20070520011714942.jpg ";
BPE. imageleftsidefilename = @ "D:/200704191728790.jpg ";
BPE. bgcolor = color. transparent;
BPE. frontfacebgcolor = color. darkorange;
BPE. leftsidebgcolor = color. bisque;

M_bitmap = (Bitmap) BPE. Draw ();
BPE. Dispose ();

(2) Disc effect:

Disk disk = new disk ();
Disk. isusebgimage = false;
Disk. bgcolor = color. Black;
Disk. imagebgfilename = @ "D:/20070520023536133.jpg ";
Disk. bordercolor = color. Black;
Disk. borderwidth = 1;
Disk. borderinnerpen = new pen (color. Red, 1 );
Disk. diskborderbrush = new lineargradientbrush (New rectangle (0, 0, 1000,100 0), color. White, color. Gray, 45f, true );
Disk. isusecontentimage = true;
Disk. imagecontentfilename = @ "D:/20070520023536133.jpg ";
Disk. diskcenterbrush = new lineargradientbrush (New rectangle (500,500,), color. Red, color. Orange, 135f );
 
M_bitmap = (Bitmap) disk. Draw ();
Disk. Dispose ();

(3) Effect of the disc with a background image (note that the hollow part of the disc is transparent to the background ):

Key code for plotting:
G. smoothingmode = smoothingmode. antialias;
G. textrenderinghint = system. Drawing. Text. textrenderinghint. antialias;
If (this. _ isusebgimage)
{
Graphicspath Gp = new graphicspath ();
GP. addrectangle (New rectangle (0, 0, 1000,100 0 ));
G. drawimage (fillphotoinzone (Bitmap) This. imagebg, GP), 0, 0 );
GP. Dispose ();
}
Else
{
G. Clear (this. _ bgcolor );
}

// Edge Area of the optical disc
Graphicspath gpborder = new graphicspath ();
Gpborder. addellipse (this. diskborder_outer );
Gpborder. addellipse (this. diskborder_inner );
Gpborder. fillmode = fillmode. Alternate;
G. setclip (gpborder );
G. fillellipse (this. _ diskborderbrush, this. diskborder_outer );
Gpborder. Dispose ();
G. resetclip ();

// Content area
Graphicspath gpcontent = new graphicspath ();
Gpcontent. addellipse (this. diskborder_inner );
Gpcontent. addellipse (this. diskcenter );
Gpcontent. fillmode = fillmode. Alternate;
G. setclip (gpcontent );
If (this. isusecontentimage)
{
G. drawimage (this. imagecontent, this. diskborder_inner, new rectangle (0, 0, this. imagecontent. Width, this. imagecontent. Height), graphicsunit. pixel );
}
Else
{
G. fillellipse (this. _ diskcontentbrush, this. diskborder_inner );
}
Gpcontent. Dispose ();
G. resetclip ();

// Disc area
Graphicspath gpbearingsurface = new graphicspath ();
Gpbearingsurface. addellipse (this. diskcenter );
Gpbearingsurface. addellipse (this. diskinner );
Gpbearingsurface. fillmode = fillmode. Alternate;
G. setclip (gpbearingsurface );
_ Diskcenterbrush = new solidbrush (color. fromargb (160,255,255,255 ));
G. fillellipse (this. _ diskcenterbrush, this. diskcenter );
Gpbearingsurface. Dispose ();
G. resetclip ();

G. drawellipse (this. _ borderpen, this. diskborder_outer );
G. drawellipse (this. _ borderinnerpen, this. diskborder_inner );
G. drawellipse (this. _ borderdiskcenterpen, this. diskcenter );
G. drawellipse (this. _ borderdiskinnerpen, this. diskinner );

// G. drawline (new pen (color. Red, 1), new point (500,100, 0), new point ));
// G. drawline (new pen (color. Red, 1), new point (0,500), new point (1000,500 ));

// Gpdiskinner. Dispose ();
Gpborder. Dispose ();

More results will be placed in the http://www.zpxp.com (radish mouse online image processing.

The effect of the handbag under WPF has been achieved:(Code on the right)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.