線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1766
推到 Plurk!
推到 Facebook!

Image 分割

答題得分者是:RaynorPao
hjlin
一般會員


發表:63
回覆:48
積分:22
註冊:2003-02-11

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-07-28 16:45:44 IP:61.56.xxx.xxx 未訂閱
請問一下,有沒有可以對 Image 做分割的 function,功能如下:當 Image 移動超過某個限定值後,就會分割成兩部分... 發表人 - hjlin 於 2003/07/28 17:42:16
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-07-28 17:11:21 IP:61.218.xxx.xxx 未訂閱
引言: 請問一下,有沒有可以對 Image 做分割的 function,功能如下:當 Image 移動超過某個限定值後,就會分割成兩塊。
    hjlin您好:    1.請您修正一下不良標題!!!    2.請參考包子兄的作品
 利用滑鼠截取 Image 的部分區域  
 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=34115
Unit1.cpp    //---------------------------------------------------------------------------    #include 
#pragma hdrstop    #include "Unit1.h"    bool gbMDown=false;
TRect grtLTRB;    #define IMAGE_WIDTH 300
#define IMAGE_HEIGHT 300    //---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
   : TForm(Owner)
{
}
//---------------------------------------------------------------------------    void __fastcall TForm1::FormCreate(TObject *Sender)
{
   Panel1->DoubleBuffered=true;       Image1->Width=IMAGE_WIDTH;
   Image1->Height=IMAGE_HEIGHT;
   Image1->Left=(Panel1->Width-Image1->Width)/2;
   Image1->Top=(Panel1->Height-Image1->Height)/2;
   Image1->Stretch=true;
   Image1->Picture->Bitmap->LoadFromFile("ImageRect1.bmp");       Image2->Width=IMAGE_WIDTH;
   Image2->Height=IMAGE_HEIGHT;
   Image2->Left=(Panel1->Width-Image2->Width)/2;
   Image2->Top=(Panel1->Height-Image2->Height)/2;
   Image2->Stretch=true;
   Image2->Canvas->Brush->Color=clWhite;
   Image2->Canvas->FillRect(Rect(0, 0, Image2->Width, Image2->Height));
   Image2->Picture->Bitmap->TransparentColor=clWhite;
   Image2->Transparent=true;       Image3->Width=IMAGE_WIDTH;
   Image3->Height=IMAGE_HEIGHT;
   Image3->Left=(Panel2->Width-Image3->Width)/2;
   Image3->Top=(Panel2->Height-Image3->Height)/2;
   Image3->Stretch=true;
   Image3->Canvas->Brush->Color=clWhite;
   Image3->Canvas->FillRect(Rect(0, 0, Image3->Width, Image3->Height));
}
//---------------------------------------------------------------------------
//取得選取的起始點    void __fastcall TForm1::Image2MouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
   gbMDown=true;
   grtLTRB.Left=X;
   grtLTRB.Top=Y;
   grtLTRB.Right=X;
   grtLTRB.Bottom=Y;
}
//---------------------------------------------------------------------------    //取得Mouse移動座標
void __fastcall TForm1::Image2MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
   if(gbMDown)
   {
      if(X<0) X=0;
      if(X>Image2->Width) X=Image2->Width;
      if(Y<0) Y=0;
      if(Y>Image2->Height) Y=Image2->Height;          grtLTRB.Right=X;
      grtLTRB.Bottom=Y;          Image2->Canvas->FillRect(Rect(0, 0, Image2->Width, Image2->Height));
      Image2->Canvas->Rectangle(grtLTRB);
   }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image2MouseUp(TObject *Sender, TMouseButton Button,
      TShiftState Shift, int X, int Y)
{
   gbMDown=false;
   Image2->Canvas->FillRect(Rect(0, 0, Image2->Width, Image2->Height));
   Image3->Canvas->FillRect(Rect(0, 0, Image3->Width, Image3->Height));
   Image3->Canvas->CopyRect(grtLTRB, Image1->Canvas, grtLTRB);
   Label2->Caption="被截取的區域: Rect("+IntToStr(grtLTRB.Left)+", "+
      IntToStr(grtLTRB.Top)+", "+IntToStr(grtLTRB.Right)+", "+
      IntToStr(grtLTRB.Bottom)+")";
}
//---------------------------------------------------------------------------    Unit1.h    //---------------------------------------------------------------------------    #ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include 
#include 
#include 
#include <Forms.hpp>
#include 
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
   TLabel *Label1;
   TPanel *Panel1;
   TPanel *Panel2;
   TLabel *Label2;
   TImage *Image1;
   TImage *Image2;
   TImage *Image3;
   void __fastcall FormCreate(TObject *Sender);
   void __fastcall Image2MouseDown(TObject *Sender, TMouseButton Button,
          TShiftState Shift, int X, int Y);
   void __fastcall Image2MouseMove(TObject *Sender, TShiftState Shift,
          int X, int Y);
   void __fastcall Image2MouseUp(TObject *Sender, TMouseButton Button,
          TShiftState Shift, int X, int Y);
private: // User declarations
public:  // User declarations
   __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
HAVE A NICE DAY FOR YOU 發表人 - axsoft 於 2003/07/28 17:35:08
hjlin
一般會員


發表:63
回覆:48
積分:22
註冊:2003-02-11

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-07-28 17:55:44 IP:61.56.xxx.xxx 未訂閱
我要的找的功能,好像不是這樣ㄟ 當 Image 超過左邊限後,超過部分會從右邊出現...(藍色部分),希望能是時即的做變化。而不是存檔後的結果。
RaynorPao
版主


發表:139
回覆:3622
積分:7025
註冊:2002-08-12

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-07-29 00:57:24 IP:61.221.xxx.xxx 未訂閱
引言: 我要的找的功能,好像不是這樣ㄟ 當 Image 超過左邊限後,超過部分會從右邊出現...(藍色部分),希望能是時即的做變化。而不是存檔後的結果。
hjlin 你好: 請參考以下的連結文章 ><>備註: 以上連結中的程式碼已經更新功能,請再重新下載 --
------
-- 若您已經得到滿意的答覆,請適時結案!! --
-- 欲知前世因,今生受者是;欲知來世果,今生做者是 --
-- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 --
系統時間:2024-05-18 4:33:40
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!