Skip to content

Instantly share code, notes, and snippets.

@cacao-soft
Created January 3, 2021 19:23
Show Gist options
  • Save cacao-soft/cbeb9c9396f6cf50ebf7049e863e228b to your computer and use it in GitHub Desktop.
Save cacao-soft/cbeb9c9396f6cf50ebf7049e863e228b to your computer and use it in GitHub Desktop.
class Bitmap
#--------------------------------------------------------------------------
# ○ クリッピング描画
# reg_bitmap : リージョン画像(黒部分を非表示)
#--------------------------------------------------------------------------
def clip_blt2(x, y, src_bitmap, src_rect, reg_bitmap)
return -1 if TRGSSX::NO_TRGSSX
apt, ai, flag = [], [], false
(reg_bitmap.height-1).downto(0) do |y|
(reg_bitmap.width).times do |x|
if x+1 == reg_bitmap.width || reg_bitmap.get_pixel(x, y).red == 0
if flag
apt.push([x,y+1], [x,y])
ai << 4
flag = false
end
else
apt.push([x,y], [x,y+1]) unless flag
flag = true
end
end
end
cppr = Win32API.new('gdi32', 'CreatePolyPolygonRgn', 'ppll', 'l')
ppt = apt.inject("") {|r,pt| r << pt.pack("ll") }
pai = ai.pack("l*")
hRgn = cppr.call(ppt, pai, ai.size, 2)
return if hRgn == nil || hRgn == 0
result = TRGSSX.clip_blt(get_base_info,
x, y, src_rect.width, src_rect.height,
src_bitmap.get_base_info, src_rect.x, src_rect.y, hRgn)
# 後始末
Region.delete_region_handles
return result
end
end
@cacao-soft
Copy link
Author

KAMESOFT さんの『ビットマップ拡張』使用し、画像でマスク処理
SS1912075641821

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment