编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛  
 
全能 ASP / PHP / ASP.NET 主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
发新话题
打印

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

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

各位大虾:
请问一下,怎么样用C++ Builder6.0实现图片旋转90度和180度.

[此贴子已经被作者于2007-7-18 0:12:26编辑过]

TOP

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Graphics::TBitmap *bufferbitmap = new Graphics::TBitmap();
bufferbitmap->Width = Image1->Height;
bufferbitmap->Height = Image1->Width;

static TRect sourcepix,destpix, fullbufferimage, fulldestimage;
fullbufferimage.left = 0;
fullbufferimage.Top = bufferbitmap->Height;
fullbufferimage.Right = bufferbitmap->Width;
fullbufferimage.Bottom = 0;

for( int y=0; y < Image1->Height; ++y)
{
for( int x =0; x < Image1->Width; ++x)
{
sourcepix.Left = x;
sourcepix.Top = y+1;
sourcepix.Right = x+1;
sourcepix.Bottom = y;
destpix.Left = y;
destpix.Top = bufferbitmap->Height - x;
destpix.Right = y + 1;
destpix.Bottom = bufferbitmap->Height - x -1;
bufferbitmap->Canvas->CopyRect(destpix,Image1->Canvas,sourcepix);
}
}
Image1->Width = bufferbitmap->Width;
Image1->Height = bufferbitmap->Height;
Image1->Picture->Bitmap->Width = bufferbitmap->Width;
Image1->Picture->Bitmap->Height = bufferbitmap->Height;
Image1->Canvas->CopyRect(fullbufferimage,bufferbitmap->Canvas,fullbufferimage);

}
//---------------------------------------------------------------------------

c++/C + 汇编 = 天下无敌

TOP

发新话题