C# Image Resizer with Canvas Handler -
I am incredibly new to C # (has just started today)
to be able to 500 x your side 500 image for a C # image resizer example with a canvas handler is required to maintain the ration will be converted to 1024x500 will it 500x500 to do but white space (canvas ) With fill the rest of space.
I will also be resizing the size of the same original image for 300 x 500, where the image will be able to resume its 1:. 1 ration and turned 300x300 and remaining space from the canvas used as white space
Can anyone help me to build a C # console application that I can understand
Here I have found that I can reasonably understand (due to good comment).
What I got with the code is that I can read it, but when it actually writes for me something I just fall apart, I primarily do HTML and CSS. Start entering JQuery and C #
Using the system; Using System.Collections.Generic; Using System.Linq; Using System.Text; System usage threading. Task; Using System.Drawing; Using System.Drawing.Imaging; Namespace ImageResizer {square ImageResize {static void Main (string [] args) {} public void ResizeImage (string OriginalFile, NewFile string, integer NewWidth, integer maxHeight, bool OnlyResizeIfWider) {System.Drawing.Image FullsizeImage = System.Drawing.Image . FromFile (OriginalFile); // Prevent the use of internal thumbnail images. FullsizeImage.RotateFlip (System.Drawing.RotateFlipType.Rotate180FlipNone); FullsizeImage.RotateFlip (System.Drawing.RotateFlipType.Rotate180FlipNone); If (only resize ifrader) {if (fullscreen width & lt; = newwuth) {nudity = full size image wide; }} Int'l NewHeight = Foolsize Image. Highlight * Nudity / Fulsize Image. With; If (NewHight> MaxHit) {// Resize with height instead of at new height = Fullscreen image. Max * MAXHIGHT / FULLISH IMAGE. height; NewHeight = MaxHit; } System.Drawing.Image NewImage = FullsizeImage.GetThumbnailImage (NewWidth, NewHeight, Blank, IntPtr.Zero); // Handle the original file so that we can overwrite it as necessary FullsizeImage.Dispose (); // Save the resized image NewImage.Save (NewFile); }}}
Try it for go; & Gt;
private void resizeImage (string path, string OriginalFilename, / * note rename * / int canvasWidth, integer CanvasHeight, / * new * / int originalWidth, integer originalHeight) {image = Image. FromFile (path + originalFilename); System.Drawing.Image Thumbnail = New Bitmap (Canvaswind, CanvasHight); // Renamed system system. Drawing. Graphics Graphic = System.Drawing.Graphics.FromImage (Thumbnail); Graphic Interpolation mode = Interpolation mode. Highquite bibbic; Graphic. Soundingmode = smoothing. High quality; Graphic.PixelOffsetMode = PixelOffsetMode.HighQuality; Graphic.composingquality = computing property High quality; / * ------------------ New code --------------- * / // ratio two ratio ratio = (double) canvaswith / (Double) rootwind; Double ratio = = (double) canvas height / (double) original hight; / / Any multiplier is the smallest ratio = ratio X
Comments
Post a Comment