[求助]怎么样让图片出现翻转
各位大虾:<br> 请问一下,怎么样用C++ Builder6.0实现图片旋转90度和180度.[align=right][color=#000066][此贴子已经被作者于2007-7-18 0:12:26编辑过][/color][/align]
<P>#include <vcl.h><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->Width = Image1->Height;<BR> bufferbitmap->Height = Image1->Width;</P>
<P> static TRect sourcepix,destpix, fullbufferimage, fulldestimage;<BR> fullbufferimage.left = 0;<BR> fullbufferimage.Top = bufferbitmap->Height;<BR> fullbufferimage.Right = bufferbitmap->Width;<BR> fullbufferimage.Bottom = 0;</P>
<P> for( int y=0; y < Image1->Height; ++y)<BR> {<BR> for( int x =0; x < Image1->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->Height - x;<BR> destpix.Right = y + 1;<BR> destpix.Bottom = bufferbitmap->Height - x -1;<BR> bufferbitmap->Canvas->CopyRect(destpix,Image1->Canvas,sourcepix);<BR> }<BR> }<BR> Image1->Width = bufferbitmap->Width;<BR> Image1->Height = bufferbitmap->Height;<BR> Image1->Picture->Bitmap->Width = bufferbitmap->Width;<BR> Image1->Picture->Bitmap->Height = bufferbitmap->Height;<BR> Image1->Canvas->CopyRect(fullbufferimage,bufferbitmap->Canvas,fullbufferimage);</P>
<P>}<BR>//---------------------------------------------------------------------------<BR></P>
页:
[1]
