Original GIF png BMP Jeg display method

Source: Internet
Author: User

///<summary>///Note Do not forget to refer to those picture units Oh, except BMP format does not need to reference any unit,///Other image formats need to refer to the corresponding picture unit///PNG---> Vcl.Imaging.pngimage///JPG---> Vcl.Imaging.jpeg///gif---> VCL.IMAGING.GIFIMG///</summary>procedureTform12.btn1click (sender:tobject);varRect1,rect2:trect;  Picture:tpicture; Op:topendialog;beginPicture := Tpicture.Create; OP:= Topendialog.Create(Nil); Try    ifOp. Execute Then    beginpicture.loadfromfile (Op.      FileName); //---------------------------------------      //if it's a animated GIF, try to get him to move .      ifExtractfileext (Op. FileName) ='. gif'  Then      begin        //This sentence does not take effect for draw and Stretchdraw, after discussion it may be that draw draws only the first frame of the GIF, so that the animation does not show, this is not a temporary solution        //use Timage to show that the animation is in effect. Tgifimage (picture.graphic). Animate: =True; End; //---------------------------------------      //Descriptive 1: The simplest way to draw, but cannot control the size of the picture, that is, when the picture is large, it will be very large,      //The original picture is not scaled in size      //The first parameter is left the second parameter is the position where the TOP is the beginning of the drawingCanvas.draw (Ten,Ten, Tgifimage (picture.graphic)); //---------------------------------------      //Figure 2: Set a rectangular range, draw the picture into the rectangle, but notice the word stretch, meaning      //stretches the image to fill the entire rectangular area, meaning the picture will deform. But the general deformation can also ah, to ensure that the image of the human eye can      //recognize how good. Rect1.left: = -; Rect1.top:= -; Rect1.width:= $; Rect1.height:= -;      Canvas.stretchdraw (Rect1, picture.graphic); //---------------------------------------      //Descriptive 3: The extension of the descriptive 2, according to the rectangular area of the length and width ratio, to stretch the picture, to ensure that the telescopic time does not deform, note jpg      //The format of the picture is not allowed to modify the size of the picture, so this method will not work, this method is only as a reference bar. Rect2.left: = -; Rect2.top:= -; Rect2.width:= -; Rect2.height:= -; //when the height or width of the picture is greater than the area, it needs to be scaled, other situations do not need      ifPicture.Graphic.Width > Rect2.width Then      beginPicture.Graphic.Width:= Round (Picture.Graphic.Width * (Rect2.width/Picture.Graphic.Width)); Picture.Graphic.Height:= Round (Picture.Graphic.Height * (Rect2.width/Picture.Graphic.Width)); End Else ifPicture.Graphic.Height > Rect2.height Then beginPicture.Graphic.Width:= Round (Picture.Graphic.Width * (Rect2.height/Picture.Graphic.Height)); Picture.Graphic.Height:= Round (Picture.Graphic.Height * (Rect2.height/Picture.Graphic.Height)); End;      Canvas.draw (Rect2.left, Rect2.top, picture.graphic); //---------------------------------------      //Display Method 4: Of course, timage brother, this is nothing to say, get an image control to display      //Image1.Picture.LoadFromFile (Op. FileName);Image1.stretch: = False;//this to control whether or not to stretch.Image1.Picture.Graphic: = picture.graphic;//or so    End; finallyPicture.free; Op.  Free; End;End;

Welcome advice, Broken GIF animation picture multi-frame problem.

Original GIF png BMP Jeg display method

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.