![]() ![]() Graphics oGraphics = Graphics.FromImage(newBMP) Create a graphic based on the new bitmap Create a new bitmap which will hold the previous resized bitmapīitmap newBMP = new Bitmap(originalBMP, newWidth, newHeight) int newHeight = newWidth / sngRatio int newHeight = 320 Calculate the new image dimensions int origWidth = originalBMP.Width Create a bitmap of the content of the fileUpload control in memoryīitmap originalBMP = new Bitmap( c:\TestPhotoQualityZero.jpg") Specify the upload directory string directory = Server.MapPath( Uploaded-Files\") If it doesn't then we just create it before going any furtherĭirectory.CreateDirectory(MapPath( Uploaded-Files")) Check if the directory we want the image uploaded to actually exists or not if (!Directory.Exists(MapPath( Uploaded-Files"))) Find the fileUpload control string filename = fileUpload.FileName ![]() MyEncoderParameters.Param = myEncoderParameter īmp1.Save( c:\TestPhotoQualityZero.jpg", jgpEncoder, myEncoderParameters) ![]() EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 50L) // myEncoderParameters.Param = myEncoderParameter // jgpEncoder, myEncoderParameters) // myEncoderParameter = new EncoderParameter(myEncoder, 100L) // myEncoderParameters.Param = myEncoderParameter // jgpEncoder, myEncoderParameters) // Save the bitmap as a JPG file with zero quality level compression.ĮncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 25L) In this case, there is only one // EncoderParameter object in the array.ĮncoderParameters myEncoderParameters = new EncoderParameters( 1) An EncoderParameters object has an array of EncoderParameter // objects. Create an Encoder object based on the GUID // for the Quality parameter category. ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg) ![]() Copy Code protected void uploadButton_Click( object sender, EventArgs e)īitmap bmp1 = new Bitmap(fileUpload.FileContent) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |