📄 faq89.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Display JPEG images</TITLE>
<META NAME="Author" CONTENT="Harold Howe">
</HEAD>
<BODY BGCOLOR="WHITE">
<CENTER>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="640">
<TR>
<TD>
<H3> Display JPEG images</H3>
<P> Use the class <TT>TJPEGImage</TT> to load the JPEG, and then use the <TT>Assign</TT> method to
draw the JPEG onto a regular <TT>TImage</TT>. Here is a code example that demonstrates how.
</p>
<pre>
<font color="green">#include <jpeg.hpp></font>
<b>void</b> <b>__fastcall</b> TForm1<b>:</b><b>:</b>Button1Click<b>(</b>TObject <b>*</b>Sender<b>)</b>
<b>{</b>
<font color="navy">// Create a TJPEGImage, and tell it to load the file conf99.jpg</font>
TJPEGImage <b>*</b>JImage <b>=</b> <b>new</b> TJPEGImage<b>;</b>
JImage<b>-></b>LoadFromFile<b>(</b><font color="blue">"conf99.jpg"</font><b>)</b><b>;</b>
<font color="navy">// Now that we have a TJEGImage, we can use Assign to</font>
<font color="navy">// copy that image into a TImage.</font>
Image1<b>-></b>Width <b>=</b> JImage<b>-></b>Width<b>;</b>
Image1<b>-></b>Height <b>=</b> JImage<b>-></b>Height<b>;</b>
Image1<b>-></b>Picture<b>-></b>Assign<b>(</b>JImage<b>)</b><b>;</b>
<b>delete</b> JImage<b>;</b>
<b>}</b>
</pre>
<P>
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.
</P>
<BR>
<IMG SRC="images/jpegdisplay.jpg" BORDER=0 ALIGN="BOTTOM" width="661" height="502"> <BR>
<H4>Figure 1. Displaying JPEG files from a BCB program</H4>
<BR>
<TABLE BORDER=1 CELLPADDING=10 CELLSPACING=0 WIDTH="100%">
<TR> <TD colspan = 2><B>Downloads for this FAQ</B> </TD> </TR>
<TR> <TD><TT><a HREF="download/faq89.zip">faq89.zip</a></TT></TD><TD>Source code for this FAQ.</TD> </TR>
</TABLE>
</TD> </TR>
</TABLE>
</CENTER>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -