数学建模社区-数学中国

标题: Display JPEG images [打印本页]

作者: 韩冰    时间: 2005-1-26 12:43
标题: Display JPEG images

Display JPEG images

$ g& l. F! j% d& |) V$ A( ^, N

% |8 b6 ?6 \8 R9 z3 kAnswer - `, I! J) B. K/ L. ~" b |Use the class TJPEGImage to load the JPEG, and then use the Assign method to draw the JPEG onto a regular TImage. Here is a code example that demonstrates how.

" }" m9 G5 g d4 N' P

#include <jpeg.hpp>

% T# z$ Y/ u% }4 k+ E. V5 w" c9 w

void __fastcall TForm1::Button1Click(TObject *Sender)3 @0 q! F% G' c: w/ P% z3 n { : W* R+ y% f; {# D' p! j // Create a TJPEGImage, and tell it to load the file conf99.jpg - ?( E" }; E' B& d7 V4 | TJPEGImage *JImage = new TJPEGImage;; ~5 K$ H; s" v( U* V7 S/ R/ } JImage->LoadFromFile("conf99.jpg");

& k& a6 {! k: m! _

// Now that we have a TJEGImage, we can use Assign to' l/ c' L7 L0 U& p // copy that image into a TImage.- g5 e7 S- s9 Y& I$ p$ c2 f5 t Image1->Width = JImage->Width; 6 Y S5 I N2 Z! U+ X Image1->Height = JImage->Height; + s) f5 y/ d6 g. Z5 o Image1->icture->Assign(JImage);

`& `) L4 B+ o$ k$ F" v

delete JImage;5 |, X" X$ E6 z: j* R5 x/ X9 g }

+ G0 D9 m- M/ `) r$ b7 k3 z, ]# N

Figure 1 shows the program in action. The image is a picture of me and my son playing games during the DirectX madness event at Borcon 99. The picture was taken by Danny Thorpe, and its part of his photo gallery on the community website. Fortunately for you, Danny took a picture of my best side.

# T* }9 L' E: `2 s3 j

; M$ @9 p0 c! H, Y8 A6 c: {. T& N






欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5