[Source]D3D Color Pick

Sabtu, 15 Desember 2012

[Source]D3D Color Pick





Pertama convert pict di bawah ini menggunakan "image to array" / "image to byte"
Setelah itu masukan code hasil convert td ke "Sprite" (sama seperti memunculkan gambar di d3d menu)




Masukan Ramuan nya
Code:
class ColorPickClass
{ 
 
  public:
 
 ColorPickClass()
 {   
   iPickedR=255;
          iPickedG=255; 
          iPickedB=255;

          //iSpriteLeftPos=?
          //iSpriteTopPos=?
          //iSpriteWidth=?
          //iSpriteHeight=?
 
 }
 ~ColorPickClass()
 {
  
 }

        int iPickedR;
        int iPickedG; 
        int iPickedB;        
 
  private:
 HWND CoD4Handle;
        HDC CoD4DC;
 POINT pPoint;
 RECT wndRect;

        int iPosX; 
        int iPosY; 
        int iSpriteLeftPos;
        int iSpriteTopPos;
        int iSpriteWidth;
        int iSpriteHeight;        

        void DoColorPicker( );   
};

ColorPickClass CColorPick;


lalu panggil fungsi di atas dengan code di bwah ini
(edit & sesuaikan dengan code d3d agan)

void ColorPickClass::DoColorPicker( )
{  
  GetCursorPos( &pPoint );
  iPosX = pPoint.x;
  iPosY = pPoint.y;    
  
  wndRect.left   = iSpriteLeftPos; 
  wndRect.top    = iSpriteTopPos; 
  wndRect.right  = wndRect.left + iSpriteWidth; 
  wndRect.bottom = wndRect.top + iSpriteHeight;

  //CoD4Handle = GetForegroundWindow();    
  CoD4Handle = FindWindow(0, "Call of Duty 4");  
  CoD4DC     = GetDC(CoD4Handle);
  GetClientRect(CoD4Handle, &wndRect);
  COLORREF Pixel = GetPixel(CoD4DC, iPosX, iPosY); 
 
  if (iPosX >= iSpriteLeftPos && iPosX <= (iSpriteLeftPos + iSpriteWidth) &&
      iPosY >= iSpriteTopPos  && iPosY <= (iSpriteTopPos + iSpriteHeight) &&
     (GetAsyncKeyState( VK_LBUTTON ) &1==1 ))
  {
    iPickedR = GetRValue(pixel);
    iPickedG = GetGValue(pixel); 
    iPickedB = GetBValue(pixel);
  }
}


Example usage:
wCrosshair( Device, 255, CColorPick.iPickedR, CColorPick.iPickedG, CColorPick.iPickedB );
"Jangan segan untuk bertanya, bila agan kesulitan silahkan tinggalkan komentar di bawah, maka akan saya bantu semaksimal mungkin "

1 komentar:


free counters