native implementation of DoGetPixel()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57823 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -443,25 +443,33 @@ bool wxWindowDCImpl::DoFloodFill(wxCoord x, wxCoord y,
|
|||||||
|
|
||||||
bool wxWindowDCImpl::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const
|
bool wxWindowDCImpl::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const
|
||||||
{
|
{
|
||||||
#if wxUSE_IMAGE
|
GdkImage* image = NULL;
|
||||||
// Generic (and therefore rather inefficient) method.
|
if (m_gdkwindow)
|
||||||
// Could be improved.
|
{
|
||||||
wxMemoryDC memdc;
|
const int x = LogicalToDeviceX(x1);
|
||||||
wxBitmap bitmap(1, 1);
|
const int y = LogicalToDeviceY(y1);
|
||||||
memdc.SelectObject(bitmap);
|
wxRect rect;
|
||||||
memdc.Blit(0, 0, 1, 1, GetOwner(), x1, y1);
|
gdk_drawable_get_size(m_gdkwindow, &rect.width, &rect.height);
|
||||||
memdc.SelectObject(wxNullBitmap);
|
if (rect.Contains(x, y))
|
||||||
|
image = gdk_drawable_get_image(m_gdkwindow, x, y, 1, 1);
|
||||||
wxImage image = bitmap.ConvertToImage();
|
}
|
||||||
col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0));
|
if (image == NULL)
|
||||||
return true;
|
{
|
||||||
#else // !wxUSE_IMAGE
|
*col = wxColour();
|
||||||
wxUnusedVar(x1);
|
|
||||||
wxUnusedVar(y1);
|
|
||||||
wxUnusedVar(col);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
#endif // wxUSE_IMAGE/!wxUSE_IMAGE
|
}
|
||||||
|
GdkColormap* colormap = gdk_image_get_colormap(image);
|
||||||
|
const unsigned pixel = gdk_image_get_pixel(image, 0, 0);
|
||||||
|
if (colormap == NULL)
|
||||||
|
*col = pixel ? m_textForegroundColour : m_textBackgroundColour;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GdkColor c;
|
||||||
|
gdk_colormap_query_color(colormap, pixel, &c);
|
||||||
|
col->Set(c.red >> 8, c.green >> 8, c.blue >> 8);
|
||||||
|
}
|
||||||
|
g_object_unref(image);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
|
void wxWindowDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
|
||||||
|
Reference in New Issue
Block a user