Class: Resedit::PngImage
- Inherits:
-
Image
- Object
- Image
- Resedit::PngImage
show all
- Defined in:
- lib/resedit/image/png_image.rb
Constant Summary
Constants inherited
from Image
Image::FORMAT_32BIT, Image::FORMAT_INDEXED, Image::TYPE_BMP, Image::TYPE_PNG
Instance Attribute Summary
Attributes inherited from Image
#height, #width
Instance Method Summary
collapse
Methods inherited from Image
#fill, #hline, #vline
Constructor Details
Returns a new instance of PngImage.
8
9
10
|
# File 'lib/resedit/image/png_image.rb', line 8
def initialize
@img = nil
end
|
Instance Method Details
#create(width, height, format) ⇒ Object
21
22
23
24
|
# File 'lib/resedit/image/png_image.rb', line 21
def create(width, height, format)
@width, @height = width, height
@img = ChunkyPNG::Image.new(width, height, ChunkyPNG::Color::TRANSPARENT)
end
|
#getPixel(x, y) ⇒ Object
12
13
14
15
|
# File 'lib/resedit/image/png_image.rb', line 12
def getPixel(x, y)
col = @img[x, y]
return (col<<24 & 0xFFFFFFFF) | (col>>8)
end
|
#load(filename) ⇒ Object
31
32
33
34
35
|
# File 'lib/resedit/image/png_image.rb', line 31
def load(filename)
@img = ChunkyPNG::Image.from_file(filename)
@width = @img.width
@height = @img.height
end
|
#save(filename) ⇒ Object
26
27
28
29
|
# File 'lib/resedit/image/png_image.rb', line 26
def save(filename)
filename+='.png' if filename[-4..-1].downcase() != '.png'
@img.save(filename)
end
|
#setPixel(x, y, color) ⇒ Object
17
18
19
|
# File 'lib/resedit/image/png_image.rb', line 17
def setPixel(x, y, color)
@img[x, y] = ((color<<8 & 0xFFFFFFFF) | (color>>24))
end
|