Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Bitmap.cpp
- Revision:
- 3:328a79795feb
- Parent:
- 2:6d2a681c5cdf
- Child:
- 5:c599a5c5256e
--- a/Bitmap.cpp Wed Apr 18 22:32:47 2012 +0000 +++ b/Bitmap.cpp Wed Apr 18 23:59:09 2012 +0000 @@ -6,8 +6,8 @@ bool Bitmap::isPixel(int pixel) { if (pixel > width) { return false; } - if ((row_data[pixel/32]>>(pixel%32)) & 0x01) { return true; } - else { return false; } + if ((row_data[pixel/32]>>(pixel%32)) & 0x01) { return false; } + else { return true; } } Bitmap::Bitmap () { @@ -21,17 +21,14 @@ fclose(fp); free(row_data); } - printf("Opening\n\r"); fp = fopen(filename, "rb"); loaded = true; - printf("Opened\n\r"); fseek(fp, OFFSET_LOCATION, SEEK_SET); fread((char *) &offset, 1, 4, fp); fseek(fp, WIDTH_LOCATION, SEEK_SET); fread((char *) &width, 1, 4, fp); fread(&height, sizeof(long), 1, fp); fseek(fp, HEIGHT_LOCATION, SEEK_SET); - printf("%x,%x,%x\n\r", offset, width, height); row_size = (width % 32) ? (width / 32) + 1 : width / 32; row_data = (long *) malloc(row_size * sizeof(long)); return true; @@ -40,10 +37,9 @@ bool Bitmap::setRow(int row) { if (loaded) { row_num = row; - fseek(fp, offset + row * row_size, SEEK_SET); + fseek(fp, offset + row * row_size*sizeof(long), SEEK_SET); for (int i = 0; i < row_size; i++) { - fscanf(fp,"%4ld", row_data + i); - printf("%4ld\n\r", row_data[i]); + fread(row_data + i, sizeof(long), 1, fp); } return true; } else {