[PATCH 1/2] utils: use always fwrite to write bitmap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Make easier to check error on next patch
---
 server/spice-bitmap-utils.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/server/spice-bitmap-utils.c b/server/spice-bitmap-utils.c
index 8d6e7c6..21d43bf 100644
--- a/server/spice-bitmap-utils.c
+++ b/server/spice-bitmap-utils.c
@@ -147,17 +147,14 @@ static void dump_palette(FILE *f, SpicePalette* plt)
 
 static void dump_line(FILE *f, uint8_t* line, uint16_t n_pixel_bits, int width, int row_size)
 {
-    int i;
+    static char zeroes[4] = { 0 };
     int copy_bytes_size = SPICE_ALIGN(n_pixel_bits * width, 8) / 8;
 
     fwrite(line, 1, copy_bytes_size, f);
-    if (row_size > copy_bytes_size) {
-        // each line should be 4 bytes aligned
-        for (i = copy_bytes_size; i < row_size; i++) {
-            fprintf(f, "%c", 0);
-        }
-    }
+    // each line should be 4 bytes aligned
+    fwrite(zeroes, 1, row_size - copy_bytes_size, f);
 }
+
 void dump_bitmap(SpiceBitmap *bitmap)
 {
     static uint32_t file_id = 0;
@@ -235,7 +232,7 @@ void dump_bitmap(SpiceBitmap *bitmap)
     }
 
     /* writing the bmp v3 header */
-    fprintf(f, "BM");
+    fwrite("BM", 2, 1, f);
     fwrite(&file_size, sizeof(file_size), 1, f);
     tmp_u16 = alpha ? 1 : 0;
     fwrite(&tmp_u16, sizeof(tmp_u16), 1, f); // reserved for application
-- 
2.4.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]