# DC#draw\_bitmap with logical\_function on Windows

**URL:** <https://www.ruby-forum.com/t/dc-draw-bitmap-with-logical-function-on-windows/182912>\
**Category:** wxRuby\
**Created:** [February 4, 2010, 6:51pm UTC](https://www.ruby-forum.com/t/dc-draw-bitmap-with-logical-function-on-windows/182912 "2010-02-04T18:51:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![valentin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f19dbf/32.png) [@valentin](https://www.ruby-forum.com/u/valentin)\
**Post date:** [February 4, 2010, 6:51pm UTC](https://www.ruby-forum.com/t/dc-draw-bitmap-with-logical-function-on-windows/182912/1 "2010-02-04T18:51:31Z")

</div>

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?
