Gitweb links:
...log
http://git.netsurf-browser.org/libnsbmp.git/shortlog/64b9b44fbbda9effa6beb57907d9501d2bdd225f
...commit
http://git.netsurf-browser.org/libnsbmp.git/commit/64b9b44fbbda9effa6beb57907d9501d2bdd225f
...tree
http://git.netsurf-browser.org/libnsbmp.git/tree/64b9b44fbbda9effa6beb57907d9501d2bdd225f
The branch, master has been updated
via 64b9b44fbbda9effa6beb57907d9501d2bdd225f (commit)
via a7c76ab477f4f35f819515c7d8064e29893734bd (commit)
from 7ad3603ae4358c131cebe112d85b34639a8d55bc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/libnsbmp.git/commit/?id=64b9b44fbbda9effa6beb57907d9501d2bdd225f
commit 64b9b44fbbda9effa6beb57907d9501d2bdd225f
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
add simple netsurf bitmap
diff --git a/test/bmp/ns.bmp b/test/bmp/ns.bmp
new file mode 100644
index 0000000..116946e
Binary files /dev/null and b/test/bmp/ns.bmp differ
commitdiff
http://git.netsurf-browser.org/libnsbmp.git/commit/?id=a7c76ab477f4f35f819515c7d8064e29893734bd
commit a7c76ab477f4f35f819515c7d8064e29893734bd
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
allow the bmp decode test program to take a filename for the output
diff --git a/test/decode_bmp.c b/test/decode_bmp.c
index c0d6500..2651897 100644
--- a/test/decode_bmp.c
+++ b/test/decode_bmp.c
@@ -27,6 +27,29 @@ unsigned char *bitmap_get_buffer(void *bitmap);
size_t bitmap_get_bpp(void *bitmap);
void bitmap_destroy(void *bitmap);
+static void write_ppm(FILE* fh, const char *name, struct bmp_image *bmp)
+{
+ uint16_t row, col;
+ uint8_t *image;
+
+ fprintf(fh, "P3\n");
+ fprintf(fh, "# %s\n", name);
+ fprintf(fh, "# width %u \n", bmp->width);
+ fprintf(fh, "# height %u \n", bmp->height);
+ fprintf(fh, "%u %u 256\n", bmp->width, bmp->height);
+
+ image = (uint8_t *) bmp->bitmap;
+ for (row = 0; row != bmp->height; row++) {
+ for (col = 0; col != bmp->width; col++) {
+ size_t z = (row * bmp->width + col) * BYTES_PER_PIXEL;
+ fprintf(fh, "%u %u %u ",
+ image[z],
+ image[z + 1],
+ image[z + 2]);
+ }
+ fprintf(fh, "\n");
+ }
+}
int main(int argc, char *argv[])
{
@@ -40,12 +63,21 @@ int main(int argc, char *argv[])
bmp_image bmp;
size_t size;
unsigned short res = 0;
+ FILE *outf = stdout;
- if (argc != 2) {
- fprintf(stderr, "Usage: %s image.bmp\n", argv[0]);
+ if (argc < 2) {
+ fprintf(stderr, "Usage: %s image.bmp [out]\n", argv[0]);
return 1;
}
+ if (argc > 2) {
+ outf = fopen(argv[2], "w+");
+ if (outf == NULL) {
+ fprintf(stderr, "Unable to open %s for writing\n",
argv[2]);
+ return 2;
+ }
+ }
+
/* create our bmp image */
bmp_create(&bmp, &bitmap_callbacks);
@@ -56,7 +88,7 @@ int main(int argc, char *argv[])
code = bmp_analyse(&bmp, size, data);
if (code != BMP_OK) {
warning("bmp_analyse", code);
- res = 1;
+ res = 3;
goto cleanup;
}
@@ -68,36 +100,21 @@ int main(int argc, char *argv[])
/* allow partially decoded images */
if ((code != BMP_INSUFFICIENT_DATA) &&
(code != BMP_DATA_ERROR)) {
- res = 1;
+ res = 4;
goto cleanup;
}
/* skip if the decoded image would be ridiculously large */
if ((bmp.width * bmp.height) > 200000) {
- res = 1;
+ res = 5;
goto cleanup;
}
}
- printf("P3\n");
- printf("# %s\n", argv[1]);
- printf("# width %u \n", bmp.width);
- printf("# height %u \n", bmp.height);
- printf("%u %u 256\n", bmp.width, bmp.height);
-
- {
- uint16_t row, col;
- uint8_t *image;
- image = (uint8_t *) bmp.bitmap;
- for (row = 0; row != bmp.height; row++) {
- for (col = 0; col != bmp.width; col++) {
- size_t z = (row * bmp.width + col) *
BYTES_PER_PIXEL;
- printf("%u %u %u ", image[z],
- image[z + 1],
- image[z + 2]);
- }
- printf("\n");
- }
+ write_ppm(outf, argv[1], &bmp);
+
+ if (argc > 2) {
+ fclose(outf);
}
cleanup:
-----------------------------------------------------------------------
Summary of changes:
test/bmp/ns.bmp | Bin 0 -> 1162 bytes
test/decode_bmp.c | 65 +++++++++++++++++++++++++++++++++--------------------
2 files changed, 41 insertions(+), 24 deletions(-)
create mode 100644 test/bmp/ns.bmp
diff --git a/test/bmp/ns.bmp b/test/bmp/ns.bmp
new file mode 100644
index 0000000..116946e
Binary files /dev/null and b/test/bmp/ns.bmp differ
diff --git a/test/decode_bmp.c b/test/decode_bmp.c
index c0d6500..2651897 100644
--- a/test/decode_bmp.c
+++ b/test/decode_bmp.c
@@ -27,6 +27,29 @@ unsigned char *bitmap_get_buffer(void *bitmap);
size_t bitmap_get_bpp(void *bitmap);
void bitmap_destroy(void *bitmap);
+static void write_ppm(FILE* fh, const char *name, struct bmp_image *bmp)
+{
+ uint16_t row, col;
+ uint8_t *image;
+
+ fprintf(fh, "P3\n");
+ fprintf(fh, "# %s\n", name);
+ fprintf(fh, "# width %u \n", bmp->width);
+ fprintf(fh, "# height %u \n", bmp->height);
+ fprintf(fh, "%u %u 256\n", bmp->width, bmp->height);
+
+ image = (uint8_t *) bmp->bitmap;
+ for (row = 0; row != bmp->height; row++) {
+ for (col = 0; col != bmp->width; col++) {
+ size_t z = (row * bmp->width + col) * BYTES_PER_PIXEL;
+ fprintf(fh, "%u %u %u ",
+ image[z],
+ image[z + 1],
+ image[z + 2]);
+ }
+ fprintf(fh, "\n");
+ }
+}
int main(int argc, char *argv[])
{
@@ -40,12 +63,21 @@ int main(int argc, char *argv[])
bmp_image bmp;
size_t size;
unsigned short res = 0;
+ FILE *outf = stdout;
- if (argc != 2) {
- fprintf(stderr, "Usage: %s image.bmp\n", argv[0]);
+ if (argc < 2) {
+ fprintf(stderr, "Usage: %s image.bmp [out]\n", argv[0]);
return 1;
}
+ if (argc > 2) {
+ outf = fopen(argv[2], "w+");
+ if (outf == NULL) {
+ fprintf(stderr, "Unable to open %s for writing\n",
argv[2]);
+ return 2;
+ }
+ }
+
/* create our bmp image */
bmp_create(&bmp, &bitmap_callbacks);
@@ -56,7 +88,7 @@ int main(int argc, char *argv[])
code = bmp_analyse(&bmp, size, data);
if (code != BMP_OK) {
warning("bmp_analyse", code);
- res = 1;
+ res = 3;
goto cleanup;
}
@@ -68,36 +100,21 @@ int main(int argc, char *argv[])
/* allow partially decoded images */
if ((code != BMP_INSUFFICIENT_DATA) &&
(code != BMP_DATA_ERROR)) {
- res = 1;
+ res = 4;
goto cleanup;
}
/* skip if the decoded image would be ridiculously large */
if ((bmp.width * bmp.height) > 200000) {
- res = 1;
+ res = 5;
goto cleanup;
}
}
- printf("P3\n");
- printf("# %s\n", argv[1]);
- printf("# width %u \n", bmp.width);
- printf("# height %u \n", bmp.height);
- printf("%u %u 256\n", bmp.width, bmp.height);
-
- {
- uint16_t row, col;
- uint8_t *image;
- image = (uint8_t *) bmp.bitmap;
- for (row = 0; row != bmp.height; row++) {
- for (col = 0; col != bmp.width; col++) {
- size_t z = (row * bmp.width + col) *
BYTES_PER_PIXEL;
- printf("%u %u %u ", image[z],
- image[z + 1],
- image[z + 2]);
- }
- printf("\n");
- }
+ write_ppm(outf, argv[1], &bmp);
+
+ if (argc > 2) {
+ fclose(outf);
}
cleanup:
--
NetSurf BMP Decoder
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org