. Net to automatically scale down or zoom in the proportion of uploaded images,. net to upload images

Source: Internet
Author: User

. Net to automatically scale down or zoom in the proportion of uploaded images,. net to upload images

This example shows how to automatically scale down or zoom in the proportion of images Uploaded By. Net. It is a very practical function. Share it with you for your reference. The specific method is as follows:

//// <Summary> /// scale down the image proportionally, automatically calculate the width /// </summary> /// <param name = "strOldPic"> source image file name (including path) </param> /// <param name = "strNewPic"> zoom out and save it as a file name (including a path) </param> /// <param name = "intHeight"> zoom down to height </param> public void SmallPicWidth (string strOldPic, string strNewPic, int intHeight) {System. drawing. bitmap objPic, objNewPic; try {objPic = new System. drawing. bitmap (strOldPic); int intWidth = (intHeight/objPic. height) * objPic. width; objNewPic = new System. drawing. bitmap (objPic, intWidth, intHeight); objNewPic. save (strNewPic);} catch (Exception exp) {throw exp;} finally {objPic = null; objNewPic = null ;}} /** /// <summary> // zoom out the image // </summary> /// <param name = "strOldPic"> source image file name (including path) </param> /// <param name = "strNewPic"> zoom out and save it as a file name (including a path) </param> /// <param name = "intWidth"> width </param> /// <param name = "intHeight"> height </param> public void SmallPic (string strOldPic, string strNewPic, int intWidth, int intHeight) {System. drawing. bitmap objPic, objNewPic; try {objPic = new System. drawing. bitmap (strOldPic); objNewPic = new System. drawing. bitmap (objPic, intWidth, intHeight); objNewPic. save (strNewPic);} catch (Exception exp) {throw exp;} finally {objPic = null; objNewPic = null ;}}

We hope that the examples described in this article will provide some reference value for your asp.net program design.


Who has the net image automatically scaled out source code?

It's easy to wait for proportional scaling. The idea is that the length or width is fixed, and the other side is calculated based on the scaling ratio, and then a thumbnail is generated according to the common scaling method.

Programming (C #, C, C ++, java, and Net can be used in any language) to import images, zoom in and out, and display the magnification of zoom in and out.

Includes the following programming:

[Image decoding]
There is no specified format for image enlargement. Therefore, various compression, orchestration, format, and color depth must be processed.] How can we deal with the blocking effect of image enlargement? You need to compare and select the process, and then there are many methods and effects;
Image Display] The window needs to be opened to enlarge the image. The display range is determined based on the pixel depth of the current window and the display device of the border. We are also concerned about Image Browsing operations, using the scroll bar when you view some image-related operations.

Related Article

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.