[Original] Multiple JPG files merge into a file in additional form

xiaoxiao2021-03-05  25

There are friends in DFW:

There are multiple JPG files, such as: 1.jpg2.jpg3.jpg ... How to combine these files into a new JPG file in additional form? That is to say 1.jpg as the first page, 2.jpg As a second page, such push.

Citing it, the idea is to decode each JPEG file and then spliced ​​and then encoded as JPEG.

Uses ..., JPEG; ...... Procedure TForm1.Button1Click (Sender: Tobject); VAR JP1, JP2, JP: TJPEGIMAGE; BMP_T, BMP: Tbitmap; Begin JP1: = TjpegImage.create; JP2: = TjpegImage .Create; jp: = tjpegimage.create; try jp1.loadfromfile ('c: /1.jpg'); jp2.loadfromfile ('c: /2.jpg'); bmp: = tbitmap.create; bmp_t: = Tbitmap .Create; bmp.width: = jp1.width; bmp.height: = jp1.Height jp2.height; bmp_t.ssign (jp1); bmp.canvas.draw (0, 0, bmp_t); bmp_t.assign JP2); bmp.canvas.draw (0, jp1.height, jp2); jp.assign (bmp); jp.savetofile ('c: /0.jpg'); finally bmp.free; bmp_t.free; end; Finally jp1.free; jp2.free; jp.free; end; end;

The two original JPEG images are the same, if the image width may not match, you can calculate the maximum width of all pictures, and then draw it.

Due to lazy research JPEG's file structure and compression algorithm, take the JPEG unit with Delphi to lazy, huh, huh

转载请注明原文地址:https://www.9cbs.com/read-36098.html

New Post(0)