| private void Page_Load(object sender, System.EventArgs e)
|
| {
|
| // Create instance of PhotoSprite |
| Graphic MyGraphic = new PhotoSprite.Graphic();
|
| |
| // Original image name |
| MyGraphic.SourceFile = Server.MapPath( "/images/demo.jpg" );
|
| // Destination image name, and can make the same as the original image name |
| MyGraphic.DestFile = Server.MapPath( "/images/tmp/resize.jpg" );
|
| |
| // Fit mode |
| // Width, fixing the destination width |
| // Height, fixing the destination height |
| // WidthHeight, auto-fit the destination width and height |
| // Percent, the destination width and height is the percent of the origin |
| // None, stretching the image to fill the destination width and height |
| // Note: |
| // The width and height will be invalid if you use percent fit mode, |
| // however, the percent will be invalid if you use other fit mode. |
| MyGraphic.Fit = PhotoSprite.Graphic.FitMode.None;
|
| |
| // Destination image width |
| MyGraphic.Width = 200;
|
| |
| // Destination image height |
| MyGraphic.Height = 200;
|
| |
| // If you use percent fit mode, you must use decimal fraction, not integer |
| // The following code shows that the destination is 50 percent of origin image. |
| // MyGraphic.Percent= 0.5 |
| |
| // Resizing image |
| MyGraphic.Resize();
|
| |
| |
| // Show the contrastive effect |
| SrcImage.Src = "/images/demo.jpg";
|
| DstImage.Src = "/images/tmp/resize.jpg";
|
| } |
|