some fixes

This commit is contained in:
John Bintz 2023-10-29 08:58:39 -04:00
parent d4f5ff8a99
commit db7958fcf2
3 changed files with 89 additions and 88 deletions

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2023 TheIndustriousRabbit Copyright (c) 2023 John Bintz
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View File

@ -1,3 +1,7 @@
# png-to-ilbm # png-to-ilbm
Convert PNG images to IFF ILBM images using Ruby. Convert PNG images to IFF ILBM images using Ruby, preserving palette indexes.
Copyright 2023 John Bintz. Learn more at https://theindustriousrabbit.com/
Licensed under the MIT License.

View File

@ -10,9 +10,6 @@
# #
# * http://etwright.org/lwsdk/docs/filefmts/ilbm.html # * http://etwright.org/lwsdk/docs/filefmts/ilbm.html
# * [ ] AMOS and ADPro fail on an image that's less than 8 pixels wide?
# * DPaint can load it, other apps get weird
require 'rmagick' require 'rmagick'
class PixelColor class PixelColor
@ -143,8 +140,8 @@ module IFF
data_bytes_count = data_bytes.count data_bytes_count = data_bytes.count
output = self.class.name.split("::").last.unpack("C*") + output = self.class.name.split("::").last.unpack("C*") +
[data_bytes_count].pack("N").unpack("C*") + [data_bytes_count].pack("N").unpack("C*") +
data_bytes data_bytes
# pad chunk # pad chunk
output << 0 if data_bytes_count.odd? output << 0 if data_bytes_count.odd?
@ -239,11 +236,11 @@ module IFF
def to_bytes def to_bytes
"ILBM".unpack("C*") + "ILBM".unpack("C*") +
bmhd.to_bytes + bmhd.to_bytes +
cmap.to_bytes + cmap.to_bytes +
camg.to_bytes + camg.to_bytes +
# body is always last # body is always last
body.to_bytes body.to_bytes
end end
end end