E
hallo,
ich programmiere einen einfachen ColorPicker und habe das Problem, dass mein Pickerfield gedreht angezeigt wird m wärend die MouseMove Funktion korrekt ist.
Wenn ich also einen einfachen Gradienten erzeuge, der von Oben Rot nach Unten Schwarz wird, dann wird mir der falsche Wert angezeigt.
CODE:
im Header habe ich definiert:
private:
COLORREF m_crData[320*240];
BITMAPINFO m_bmi;
im Oninit habe ich folgenden Code:
for(int y = 240 - 1; y >=0; y--) //lines
{
for(int x = 0; x < 320; x++)
{
this->m_crData[y * 320 + x] = RGB(y*240/255, x*255/320, 64);
}
}
ZeroMemory(&m_bmi, sizeof(BITMAPINFO));
this->m_bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
this->m_bmi.bmiHeader.biWidth = 320;
this->m_bmi.bmiHeader.biHeight = 240;
this->m_bmi.bmiHeader.biPlanes = 1;
this->m_bmi.bmiHeader.biBitCount = 32;
this->m_bmi.bmiHeader.biCompression = BI_RGB;
in der OnPaintanweisung steht dann:
if(!SetDIBitsToDevice(dc, 20, 20, 320, 240, 0, 0, 0, 320, this->m_crData, &this->m_bmi, DIB_RGB_COLORS))AfxMessageBox("ERROR");
in WM_MouseMove
CString str;
int pos_x, pos_y;
pos_x = point.x - 20; //rand
pos_y = point.y - 20; //rand
if(pos_x >= 0 && pos_x < 320 && pos_y >= 0 && pos_y < 240)
{
COLORREF cr = this->m_crData[pos_y * 320 + pos_x];
str.Format("RGB = {%lu, %lu, %lu}", (DWORD)GetRValue(cr), (DWORD)GetGValue(cr), (DWORD)GetBValue(cr)); }
else
{
str = "Keine Pixeldaten hier!";
}
this->SetWindowText(str);
vielen Dank für Hilfe