lzhp040424 发表于 2007-7-18 00:11

[求助]怎么样让图片出现翻转

各位大虾:<br>        请问一下,怎么样用C++ Builder6.0实现图片旋转90度和180度.
[align=right][color=#000066][此贴子已经被作者于2007-7-18 0:12:26编辑过][/color][/align]

热情依然 发表于 2007-7-29 16:59

<P>//---------------------------------------------------------------------------</P>
<P>#include &lt;vcl.h&gt;<BR>#pragma hdrstop</P>
<P>#include "Unit1.h"<BR>//---------------------------------------------------------------------------<BR>#pragma package(smart_init)<BR>#pragma resource "*.dfm"<BR>TForm1 *Form1;<BR>//---------------------------------------------------------------------------<BR>__fastcall TForm1::TForm1(TComponent* Owner)<BR> : TForm(Owner)<BR>{<BR>}<BR>//---------------------------------------------------------------------------<BR>void __fastcall TForm1::Button1Click(TObject *Sender)<BR>{<BR> Graphics::TBitmap *bufferbitmap = new Graphics::TBitmap();<BR> bufferbitmap-&gt;Width = Image1-&gt;Height;<BR> bufferbitmap-&gt;Height = Image1-&gt;Width;</P>
<P> static TRect sourcepix,destpix, fullbufferimage, fulldestimage;<BR> fullbufferimage.left = 0;<BR> fullbufferimage.Top = bufferbitmap-&gt;Height;<BR> fullbufferimage.Right = bufferbitmap-&gt;Width;<BR> fullbufferimage.Bottom = 0;</P>
<P> for( int y=0; y &lt; Image1-&gt;Height; ++y)<BR> {<BR>  for( int x =0; x &lt; Image1-&gt;Width; ++x)<BR>  {<BR>   sourcepix.Left = x;<BR>   sourcepix.Top = y+1;<BR>   sourcepix.Right = x+1;<BR>   sourcepix.Bottom = y;<BR>   destpix.Left = y;<BR>   destpix.Top = bufferbitmap-&gt;Height - x;<BR>   destpix.Right = y + 1;<BR>   destpix.Bottom = bufferbitmap-&gt;Height - x -1;<BR>   bufferbitmap-&gt;Canvas-&gt;CopyRect(destpix,Image1-&gt;Canvas,sourcepix);<BR>        }<BR> }<BR> Image1-&gt;Width = bufferbitmap-&gt;Width;<BR> Image1-&gt;Height = bufferbitmap-&gt;Height;<BR> Image1-&gt;Picture-&gt;Bitmap-&gt;Width = bufferbitmap-&gt;Width;<BR> Image1-&gt;Picture-&gt;Bitmap-&gt;Height = bufferbitmap-&gt;Height;<BR> Image1-&gt;Canvas-&gt;CopyRect(fullbufferimage,bufferbitmap-&gt;Canvas,fullbufferimage);</P>
<P>}<BR>//---------------------------------------------------------------------------<BR></P>

页: [1]

编程论坛