Commit 77d4db015c99ce7083fd5b33f0c650176fe8bc98

Authored by Eduardo Habkost
Committed by Anthony Liguori
1 parent aea2a33c

Fix vga_screen_dump_blank() PPM generation

vga_screen_dump_blank() was not generating a valid PPM file: the width of the
image made no sense (why it was multiplied by sizeof(uint32_t)?), and there was
only one sample per pixel, instead of three.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing 1 changed file with 3 additions and 2 deletions
hw/vga.c
@@ -2584,8 +2584,9 @@ static void vga_screen_dump_blank(VGAState *s, const char *filename) @@ -2584,8 +2584,9 @@ static void vga_screen_dump_blank(VGAState *s, const char *filename)
2584 { 2584 {
2585 FILE *f; 2585 FILE *f;
2586 unsigned int y, x, w, h; 2586 unsigned int y, x, w, h;
  2587 + unsigned char blank_sample[3] = { 0, 0, 0 };
2587 2588
2588 - w = s->last_scr_width * sizeof(uint32_t); 2589 + w = s->last_scr_width;
2589 h = s->last_scr_height; 2590 h = s->last_scr_height;
2590 2591
2591 f = fopen(filename, "wb"); 2592 f = fopen(filename, "wb");
@@ -2594,7 +2595,7 @@ static void vga_screen_dump_blank(VGAState *s, const char *filename) @@ -2594,7 +2595,7 @@ static void vga_screen_dump_blank(VGAState *s, const char *filename)
2594 fprintf(f, "P6\n%d %d\n%d\n", w, h, 255); 2595 fprintf(f, "P6\n%d %d\n%d\n", w, h, 255);
2595 for (y = 0; y < h; y++) { 2596 for (y = 0; y < h; y++) {
2596 for (x = 0; x < w; x++) { 2597 for (x = 0; x < w; x++) {
2597 - fputc(0, f); 2598 + fwrite(blank_sample, 3, 1, f);
2598 } 2599 }
2599 } 2600 }
2600 fclose(f); 2601 fclose(f);