Browse Source

Fix img2pal.py and improve error messages

tags/v1.8.0
Xerbo 4 years ago
parent
commit
fa10f2e908
2 changed files with 5 additions and 6 deletions
  1. +2
    -3
      main.c
  2. +3
    -3
      util/img2pal.py

+ 2
- 3
main.c View File

@@ -161,8 +161,7 @@ static int processAudio(char *filename, options_t *opts){
// Read PNG into image buffer // Read PNG into image buffer
printf("Reading %s\n", filename); printf("Reading %s\n", filename);
if(readRawImage(filename, img.prow, &img.nrow) == 0){ if(readRawImage(filename, img.prow, &img.nrow) == 0){
fprintf(stderr, "Skipping %s\n", img.name);
return 0;
exit(EPERM);
} }
}else{ }else{
// Attempt to open the audio file // Attempt to open the audio file
@@ -285,7 +284,7 @@ static int initsnd(char *filename) {
infwav.format = 0; infwav.format = 0;
audioFile = sf_open(filename, SFM_READ, &infwav); audioFile = sf_open(filename, SFM_READ, &infwav);
if (audioFile == NULL) { if (audioFile == NULL) {
fprintf(stderr, "Could not open %s for reading\n", filename);
fprintf(stderr, "Could not open %s\n", filename);
return 0; return 0;
} }




+ 3
- 3
util/img2pal.py View File

@@ -17,10 +17,10 @@ if len(sys.argv) == 1:
image = Image.open(sys.argv[1]) image = Image.open(sys.argv[1])
pixels = image.load() pixels = image.load()


sys.stdout.write("char palette[{}][3] = {{\n \"".format(image.size[1]))
sys.stdout.write("char palette[{}*3] = {{\n \"".format(image.size[1]))
for y in range(1, image.size[1]+1): for y in range(1, image.size[1]+1):
sys.stdout.write(''.join('\\x{:02x}'.format(a) for a in pixels[0, y-1])) sys.stdout.write(''.join('\\x{:02x}'.format(a) for a in pixels[0, y-1]))
if(y % 7 == 0 and y != 0): if(y % 7 == 0 and y != 0):
sys.stdout.write("\",\n \"")
sys.stdout.write("\"\n \"")


print("\"\n};")
print("\"\n};")

Loading…
Cancel
Save