mirror of
https://github.com/specht/champ.git
synced 2024-06-19 22:29:28 +00:00
fixed code size issue in pgif
This commit is contained in:
parent
68bfd5dadf
commit
a091d74dcd
7
champ.rb
7
champ.rb
|
@ -149,9 +149,7 @@ class Champ
|
||||||
go = nil
|
go = nil
|
||||||
gt = nil
|
gt = nil
|
||||||
if @record_frames
|
if @record_frames
|
||||||
gi, go, gt = Open3.popen2("./pgif 280 192 4 > #{File.join(@files_dir, 'frames.gif')}")
|
gi, go, gt = Open3.popen2("./pgif 280 192 2 > #{File.join(@files_dir, 'frames.gif')}")
|
||||||
gi.puts '000000'
|
|
||||||
gi.puts 'ffffff'
|
|
||||||
gi.puts '000000'
|
gi.puts '000000'
|
||||||
gi.puts 'ffffff'
|
gi.puts 'ffffff'
|
||||||
end
|
end
|
||||||
|
@ -221,9 +219,6 @@ class Champ
|
||||||
(2...frame_cycles.size).each do |i|
|
(2...frame_cycles.size).each do |i|
|
||||||
@cycles_per_frame << frame_cycles[i] - frame_cycles[i - 1]
|
@cycles_per_frame << frame_cycles[i] - frame_cycles[i - 1]
|
||||||
end
|
end
|
||||||
if @cycles_per_frame.size > 0
|
|
||||||
puts "Cycles per frame: #{@cycles_per_frame.inject(0) { |sum, x| sum + x } / @cycles_per_frame.size}"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
8
pgif.c
8
pgif.c
|
@ -122,6 +122,8 @@ void encode_image(uint8_t* pixels, uint8_t* previous_pixels,
|
||||||
uint8_t color_depth = 1;
|
uint8_t color_depth = 1;
|
||||||
while (colors_used > (1 << color_depth))
|
while (colors_used > (1 << color_depth))
|
||||||
color_depth++;
|
color_depth++;
|
||||||
|
if (color_depth < 2)
|
||||||
|
color_depth = 2;
|
||||||
|
|
||||||
uint16_t cropped_left = 0;
|
uint16_t cropped_left = 0;
|
||||||
uint16_t cropped_top = 0;
|
uint16_t cropped_top = 0;
|
||||||
|
@ -240,8 +242,8 @@ void encode_image(uint8_t* pixels, uint8_t* previous_pixels,
|
||||||
put_struct(&id, sizeof(id));
|
put_struct(&id, sizeof(id));
|
||||||
|
|
||||||
uint8_t lzw_minimum_code_size = color_depth;
|
uint8_t lzw_minimum_code_size = color_depth;
|
||||||
if (lzw_minimum_code_size < 2)
|
// if (lzw_minimum_code_size < 2)
|
||||||
lzw_minimum_code_size = 2;
|
// lzw_minimum_code_size = 2;
|
||||||
|
|
||||||
put8(lzw_minimum_code_size);
|
put8(lzw_minimum_code_size);
|
||||||
|
|
||||||
|
@ -343,6 +345,8 @@ int main(int argc, char** argv)
|
||||||
uint8_t color_depth = 1;
|
uint8_t color_depth = 1;
|
||||||
while (colors_used > (1 << color_depth))
|
while (colors_used > (1 << color_depth))
|
||||||
color_depth++;
|
color_depth++;
|
||||||
|
if (color_depth < 2)
|
||||||
|
color_depth = 2;
|
||||||
|
|
||||||
// write header
|
// write header
|
||||||
struct header_block header;
|
struct header_block header;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user