Convert Delphi jpg and GIF to BMP

Source: Internet
Author: User

Begin

BMP: = tbitmap. Create;

JPEG: = tsf-image. Create;

JPEG. loadfromfile (fname );

With BMP do

Begin

Pixelformat: = pf24bit;

Height: = 60;

Width: = self. rzlistbox. width;

Canvas. Brush. Color: = $00f0ede6;

Canvas. fillrect (canvas. cliprect );

Canvas. stretchdraw (bounds (0, 0, 80, 60), JPEG );

End;

// Here you can use methods such as Save.

BMP. Free;

JPEG. Free;



--------------------------------------------------------


-- Convert jpeg to BMP


Uses

JPEG;


Procedure into T ***** P (const filename: tfilename );

VaR

JPEG: tsf-image;

BMP: tbitmap;

Begin

JPEG: = tsf-image. Create;

Try

JPEG. compressionquality := 100; {default value}

JPEG. loadfromfile (filename );

BMP: = tbitmap. Create;

Try

BMP. Assign (JPEG );

BMP. savetofile (changefileext (filename, '.bmp '));

Finally

BMP. Free

End;

Finally

JPEG. Free

End;

End;





--------------------------------------------------------


-- There is a tgifimage component


Function gift ***** P (filename: string): tbitmap;

VaR

GIF: tgifimage;

Begin

GIF: = tgifimage. Create;

Try

GIF. loadfromfile (filename );

Result: = tbitmap. Create;

Result. Assign (GIF. Bitmap );

Finally

GIF. Free;

End;

End;

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.