Skip to content

Commit

Permalink
Added support for over 255 pixels, broke compatibility with write_file
Browse files Browse the repository at this point in the history
  • Loading branch information
wormyrocks committed Mar 4, 2018
1 parent 07328b0 commit 6c2d18b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
15 changes: 5 additions & 10 deletions imgprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
width = im.size[0]
height = im.size[1]

# f.write(struct.pack("@i", height))
# f.write(struct.pack("@i", width))
# f.write(struct.pack("@i", 1))
# f.write(struct.pack("@i", 1))

header = [height, width, 1, 1, 0, 0, 0, 0]
val = raw_input("Enter speed (1 is fastest): ")
speed = int(val)
header = [height>>8, height & 0xff, width>>8, width & 0xff, speed >> 8, speed & 0xff, 0, 0, 0, 0, 0, 0]

data = header;
framenum = 0
Expand All @@ -33,10 +30,8 @@
except EOFError:
break

header[3] = framenum

val = raw_input("Enter speed (1 is fastest): ")
header[2] = int(val)
header[6] = framenum >> 8
header[7] = framenum & 0xff

ba = bytearray(data)
f.write(ba)
Expand Down
11 changes: 8 additions & 3 deletions yapg.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#define DEBUG 0 // turn on for debug prints
#define RPM 500 // set rotation speed here

unsigned char pixels, revs, total_frames, speed;
uint16_t pixels, revs, total_frames, speed;

struct pixel {
unsigned char r, g, b;
Expand Down Expand Up @@ -132,8 +132,13 @@ int main() {

if( access( fname, F_OK ) != -1 ) {
fp = fopen(fname, "r");
fscanf(fp, "%c%c%c%c", &pixels, &revs, &speed, &total_frames);
char junk;
uint8_t p1, p2, r1, r2, s1, s2, f1, f2;
fscanf(fp, "%c%c%c%c%c%c%c%c", &p1, &p2, &r1, &r2, &s1, &s2, &f1, &f2);
pixels = (p1 << 8) | p2;
revs = (r1 << 8) | r2;
speed = (s1 << 8) | s2;
total_frames = (f1 << 8) | f2;
char junk;
fscanf(fp, "%c%c%c%c", &junk, &junk, &junk, &junk);
unsigned long size = pixels * revs * total_frames * sizeof(struct pixel);
frames = malloc(size);
Expand Down

0 comments on commit 6c2d18b

Please sign in to comment.