cashyy
高階會員
![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif)
![](images/icon_photo_none.gif) 發表:117 回覆:322 積分:212 註冊:2004-04-30
發送簡訊給我
|
您好!
如果要計算公式的話,小弟是不知道啦! ![]()
但如果要找圖素色彩的話,倒是可以參考下面程式碼:
如果要 class="code">
//.h
//---------------------------------------------------------------------------
#ifndef Unit2H
#define Unit2H
//---------------------------------------------------------------------------
#include
#include
#include
#include <Forms.hpp>
#include
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TImage *Image1;
TStaticText *StaticText1;
void __fastcall Image1MouseMove(TObject *Sender, TShiftState Shift,
int X, int Y);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif //.cpp
//---------------------------------------------------------------------------
#include
#pragma hdrstop #include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image1MouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
//取得Form1的DC
HDC hdc = ::GetDC(Handle);
//取得滑鼠位置的圖素色彩
COLORREF pcolor = ::GetPixel( hdc, X, Y );
//逐一用巨集取出RGB色彩值
unsigned int r = GetRValue(pcolor);
unsigned int g = GetGValue(pcolor);
unsigned int b = GetBValue(pcolor);
//將結果即時顯示在Form1標題文字中
Caption ="滑鼠位置:X = " AnsiString(X) " ,Y =" AnsiString(Y)
" ,圖素色彩:R:" AnsiString(r) "_G:" AnsiString(g)
"_B:" AnsiString(b);
//釋放Form1的DC handle
ReleaseDC(0,hdc);
}
//---------------------------------------------------------------------------
發表人 - cashyy 於 2005/07/14 21:31:50
|