Permalink
Browse files

more PNG::Image refactoring, making methods private

  • Loading branch information...
1 parent 33b6736 commit ce2b4e34e091baf8c00f57f6c42e42e1fced015d @aberant committed Jan 3, 2010
Showing with 18 additions and 18 deletions.
  1. +18 −18 lib/spittle/png/image.rb
View
@@ -1,5 +1,9 @@
module PNG
class Image
+ #color types
+ RGB = 2
+ RGBA = 3
+
class << self
def image_data( file_name )
png = open(file_name)
@@ -57,29 +61,11 @@ def write(file_name, options={})
end
end
- def to_s
- inspect
- end
-
- #color types
- RGB = 2
- RGBA = 3
-
# check for RGB or RGBA
def pixel_width
( color_type == RGB ? 3 : 4)
end
-
- def scanline_width
- # + 1 adds filter byte
- (width * pixel_width) + 1
- end
-
- def rows
- @rows ||= to_image
- end
-
def filter_encoded_rows(filter_type)
out = Array.new(height)
rows.each_with_index do |row, scanline|
@@ -107,10 +93,24 @@ def to_image
n_out
end
+ def to_s
+ inspect
+ end
+
def inspect
"#{@name} (#{height} x #{width}) [color type: #{color_type}, depth: #{depth}]"
end
+
private
+
+ def scanline_width
+ # + 1 adds filter byte
+ (width * pixel_width) + 1
+ end
+
+ def rows
+ @rows ||= to_image
+ end
def decode(current, row, data, pixel_width)
filter_type = row.shift

0 comments on commit ce2b4e3

Please sign in to comment.