Class: Win32::CaptureIE::BitMap
Overview
Constant Summary
Constants included
from Feature
Feature::DISABLED_FEATURE
Constants included
from FFI::GDI32
FFI::GDI32::ASPECTX, FFI::GDI32::ASPECTXY, FFI::GDI32::ASPECTY, FFI::GDI32::BITSPIXEL, FFI::GDI32::BI_BITFIELDS, FFI::GDI32::BI_JPEG, FFI::GDI32::BI_PNG, FFI::GDI32::BI_RGB, FFI::GDI32::BI_RLE4, FFI::GDI32::BI_RLE8, FFI::GDI32::BLACKNESS, FFI::GDI32::CLIPCAPS, FFI::GDI32::CURVECAPS, FFI::GDI32::DIB_PAL_COLORS, FFI::GDI32::DIB_RGB_COLORS, FFI::GDI32::DRIVERVERSION, FFI::GDI32::DSTINVERT, FFI::GDI32::HORZRES, FFI::GDI32::HORZSIZE, FFI::GDI32::LINECAPS, FFI::GDI32::MERGECOPY, FFI::GDI32::MERGEPAINT, FFI::GDI32::NOTSRCCOPY, FFI::GDI32::NOTSRCERASE, FFI::GDI32::NUMBRUSHES, FFI::GDI32::NUMCOLORS, FFI::GDI32::NUMFONTS, FFI::GDI32::NUMMARKERS, FFI::GDI32::NUMPENS, FFI::GDI32::PATCOPY, FFI::GDI32::PATINVERT, FFI::GDI32::PATPAINT, FFI::GDI32::PDEVICESIZE, FFI::GDI32::PLANES, FFI::GDI32::POLYGONALCAPS, FFI::GDI32::RASTERCAPS, FFI::GDI32::SRCAND, FFI::GDI32::SRCCOPY, FFI::GDI32::SRCERASE, FFI::GDI32::SRCINVERT, FFI::GDI32::SRCPAINT, FFI::GDI32::TECHNOLOGY, FFI::GDI32::TEXTCAPS, FFI::GDI32::VERTRES, FFI::GDI32::VERTSIZE, FFI::GDI32::WHITENESS
FFI::CStruct::TYPES
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Feature
disable_feature, enable_feature, feature_available?, feature_enable?, load_depended_library, load_feature, raise_if_disabled
Methods included from Util
filename_type, guess_format, maybe_enable_binmode, with_filename_or_writable, with_output_stream
Methods included from FFI::GDI32
with_delete_dc, with_delete_object
Methods included from FFI::Base
#define_ffi_entry
c_type, #define_c_struct, define_c_struct_under, define_c_type, sizeof
Constructor Details
#initialize(width, height) ⇒ BitMap
Returns a new instance of BitMap.
18
19
20
21
22
|
# File 'lib/win32/capture_ie/bitmap.rb', line 18
def initialize(width, height)
@width = width
@height = height
@data = nil
end
|
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
17
18
19
|
# File 'lib/win32/capture_ie/bitmap.rb', line 17
def height
@height
end
|
#width ⇒ Object
Returns the value of attribute width.
17
18
19
|
# File 'lib/win32/capture_ie/bitmap.rb', line 17
def width
@width
end
|
Instance Method Details
#concat_bottom!(bmp) ⇒ Object
Also known as:
<<
47
48
49
50
51
52
53
54
55
|
# File 'lib/win32/capture_ie/bitmap.rb', line 47
def concat_bottom!(bmp)
if width.zero?
replace(bmp)
else
check_bitmap_size(:width, @width, bmp.width)
@data << bmp.data
@height += bmp.height
end
end
|
#concat_right!(bmp) ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'lib/win32/capture_ie/bitmap.rb', line 58
def concat_right!(bmp)
if height.zero?
replace(bmp)
else
check_bitmap_size(:height, @height, bmp.height)
@data = rows.zip(bmp.rows).flatten.join
@width += bmp.width
end
end
|
76
77
78
79
80
81
82
|
# File 'lib/win32/capture_ie/bitmap.rb', line 76
def
= BITMAPFILEHEADER.new
.bfType = "BM".unpack("S")[0]
.bfSize = + data_size
.bfOffBits =
end
|
#create_bitmapinfo ⇒ Object
Also known as:
info
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/win32/capture_ie/bitmap.rb', line 85
def create_bitmapinfo
info = BITMAPINFO.new
info..biSize = BITMAPINFOHEADER.packed_size
info..biWidth = width
info..biHeight = -height info..biPlanes = 1
info..biBitCount = 32 info..biCompression = BI_RGB
info
end
|
#data ⇒ Object
32
33
34
|
# File 'lib/win32/capture_ie/bitmap.rb', line 32
def data
@data ||= "\0" * data_size
end
|
#data_size ⇒ Object
28
29
30
|
# File 'lib/win32/capture_ie/bitmap.rb', line 28
def data_size
width * height * 4
end
|
24
25
26
|
# File 'lib/win32/capture_ie/bitmap.rb', line 24
def
BITMAPINFOHEADER.packed_size + BITMAPFILEHEADER.packed_size
end
|
#inspect ⇒ Object
172
173
174
|
# File 'lib/win32/capture_ie/bitmap.rb', line 172
def inspect
"#<%s:0x%x @width=%d @height=%d @data=...>" % [self.class, self.object_id << 1, @height, @width]
end
|
#replace(bmp) ⇒ Object
40
41
42
43
44
|
# File 'lib/win32/capture_ie/bitmap.rb', line 40
def replace(bmp)
@width = bmp.width
@height = bmp.height
@data = bmp.data
end
|
#rows ⇒ Object
36
37
38
|
# File 'lib/win32/capture_ie/bitmap.rb', line 36
def rows
(0..height).map{|i| data[i * width * 4, width * 4] }
end
|
#save(writable, format = nil, &rmagick_filter) ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/win32/capture_ie/bitmap.rb', line 97
def save(writable, format=nil, &rmagick_filter)
format ||= guess_format(writable)
begin
load_depended_library("RMagick", "save `#{format}' format")
save_magick(writable, format, &rmagick_filter)
rescue DisabledError, LoadError => e
raise e unless format == "bmp"
if rmagick_filter and $VERBOSE
at = eval("[__FILE__, __LINE__]", rmagick_filter.binding)
warn "Ignore block argument at %s:%d because RMagick is not available." % at
end
save_bmp(writable)
end
end
|
#to_image(format = nil) ⇒ Object
132
133
134
135
136
137
138
139
140
|
# File 'lib/win32/capture_ie/bitmap.rb', line 132
def to_image(format=nil)
format ||= "bmp"
begin
to_magick(format)
rescue DisabledError, LoadError => e
raise e unless format == "bmp"
to_blob
end
end
|