GDI + learning Record (26): Displaying images-image

Source: Internet
Author: User

//Display image  var g:tgpgraphics; Img:tgpimage;  begin G: = Tgpgraphics.create (Self.Canvas.Handle);  IMG: = tgpimage.create (' c:\temp\x.jpg '); G.drawimage (IMG,x,{parameter 2, 3 is the coordinate} img.  Free; G.free; End;
//Display images by standard height and width  var g:tgpgraphics; Img:tgpimage;  begin G: = Tgpgraphics.create (Canvas.handle); IMG: = tgpimage.create (' c:\temp\x.jpg '), IMG. GetWidth, IMG.  GetHeight); Img.  Free; G.free; End;
//Display image at specified height and width  var g:tgpgraphics; Img:tgpimage;  begin G: = Tgpgraphics.create (Canvas.handle);  IMG: = tgpimage.create (' c:\temp\x.jpg '); Img.  Free; G.free; End;
//Slightly reduced image  var g:tgpgraphics; IMG, imgsmall:tgpimage;  begin G: = Tgpgraphics.create (Canvas.handle);  img:= tgpimage.create (' c:\temp\x.jpg '); Imgsmall: = img. Getthumbnailimage (nilnil., Imgsmall.getwidth  , imgsmall.getheight); Img.  Free;  Imgsmall.free; G.free; End;
//Picture Parallelogram transformvarG:tgpgraphics; Img:tgpimage;ConstPts:Array[0..2] ofTgppoint = ((x: -; Y: -), (x: About; Y: $), (x: -; Y: the));beginG: = Tgpgraphics.create (Canvas.handle); Img:= Tgpimage.create (' c:\temp\x.jpg '); G.drawimage (IMG,0,0);{This is the original picture}G.drawimage (IMG, Pgppoint (@pts),3);{After repeated testing, the sentiment is as follows: 1, only need 3 points to control the picture, not more or less. 2, point 1 control the upper right corner; Point 2 controls the upper left corner;    Point 3 controls the lower-right corner.  3, because is parallelogram, so the left bottom corner of the point (is the upper right corner of the diagonal point) program can be calculated out. }Img.  Free; G.free;End;
//algorithm comparison for image scalingvarG:tgpgraphics;  Img:tgpimage; W, H:uint;beginG: = Tgpgraphics.create (Canvas.handle); Img:= Tgpimage.create (' c:\temp\x.jpg '); W: = img.  getwidth; H: = img.  GetHeight; G.drawimage (IMG, Makerect (Ten,Ten, W, h),0,0, W, H, Unitpixel);  G.setinterpolationmode (Interpolationmodenearestneighbor); G.drawimage (IMG, Makerect (Ten, -,0.6*w,0.6*H),0,0, W, H, Unitpixel);  G.setinterpolationmode (interpolationmodehighqualitybilinear); G.drawimage (IMG, Makerect ( Max, -,0.6*w,0.6*H),0,0, W, H, Unitpixel);  G.setinterpolationmode (interpolationmodehighqualitybicubic); G.drawimage (IMG, Makerect (290, -,0.6*w,0.6*H),0,0, W, H, Unitpixel); Img.  Free; G.free;End;
Algorithm options when zooming or rotating an image:

Delphi Microsoft Description
Interpolationmodebicubic Bicubic Specifies a double three-time interpolation method. No pre-filtering is made. This mode does not apply when the image is shrunk to less than 25% of its original size.
Interpolationmodebilinear Bilinear Specifies the bilinear interpolation method. No pre-filtering is made. This mode does not apply when the image is shrunk to less than 50% of its original size.
Interpolationmodedefault Default Specifies the default mode.
Interpolationmodehigh High Specifies the high-quality interpolation method.
Interpolationmodehighqualitybicubic Highqualitybicubic Specifies a high-quality double three-time interpolation method. Perform pre-screening to ensure high-quality shrinkage. This mode produces the highest quality conversion image.
Interpolationmodehighqualitybilinear Highqualitybilinear Specifies a high-quality bilinear interpolation method. Perform pre-screening to ensure high-quality shrinkage.
Interpolationmodeinvalid Invalid The Invalid element that is equivalent to the Qualitymode enumeration.
Interpolationmodelow Low Specifies a low-quality interpolation method.
Interpolationmodenearestneighbor Nearestneighbor Specifies the nearest interpolation method.

GDI + learning Record (26): Displaying images-image

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.