Forum: wxRuby DC#draw_bitmap with logical_function on Windows

Posted by Valentine Bichkovsky (valentin)
on 2010-02-04 18:51
Hi!
While testing the app I developed (on Linux), I encountered strange
behaviour on Windows for this method:

  def draw(dc, x, y)
    dc.pen = Wx::TRANSPARENT_PEN
    dc.logical_function = Wx::COPY
    if @bitmap
      dc.draw_bitmap(@bitmap, x, y, false)
    else
      dc.brush = Wx::GREY_BRUSH
      dc.draw_rectangle(x, y, TILE_WIDTH, TILE_WIDTH)
    end
    if @mask
      dc.logical_function = Wx::AND
      dc.draw_bitmap(@mask, x, y, false)
    end
  end

On Linux (Ubuntu 9.10, Ruby 1.8.7, wxRuby 2.0.1) @mask is drawn
correctly, while on Windows (XP SP 2, Ruby 1.8.6, with 'backports' gem)
it is drawn as if logical_function was Wx::COPY.

For now, I wrote a workaround which works for Windows:

module Wx
  class DC
    def draw_bitmap(bitmap, x, y, draw_transp)
      m = MemoryDC.new
      m.select_object(bitmap)
      self.blit(x, y, bitmap.width, bitmap.height, m, 0, 0,
self.logical_function, draw_transp)
      m.select_object(Wx::NULL_BITMAP)
    end
  end
end

It this a bug or a platform feature?
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.