summaryrefslogtreecommitdiffstats
path: root/progs/samples/loadppm.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2010-05-21 09:32:38 -0700
committerEric Anholt <[email protected]>2010-05-21 12:20:39 -0700
commit68fc4b415e322f6744299e39864fbc377c6eff74 (patch)
tree4bafffd8b0105174f3c5c0ae327a005be9145990 /progs/samples/loadppm.c
parente4f4489e3fc0b36d72821b55794fb843b2b7fa5f (diff)
Remove demos that have moved to git+ssh://git.freedesktop.org/git/mesa/demos.
The remaining programs are ones I've had difficulty finding a build environment for to make the build system or are unit tests that should probably live next to their code instead. Hopefully people can bring over the build for remaining pieces they care about.
Diffstat (limited to 'progs/samples/loadppm.c')
-rw-r--r--progs/samples/loadppm.c74
1 files changed, 0 insertions, 74 deletions
diff --git a/progs/samples/loadppm.c b/progs/samples/loadppm.c
deleted file mode 100644
index adae9b491e4..00000000000
--- a/progs/samples/loadppm.c
+++ /dev/null
@@ -1,74 +0,0 @@
-
-typedef struct {
- size_t sizeX, sizeY;
- GLubyte *data;
-} PPMImage;
-
-static PPMImage *LoadPPM(const char *filename)
-{
- char buff[16];
- PPMImage *result;
- FILE *fp;
- int maxval, w, h;
-
- fp = fopen(filename, "rb");
- if (!fp)
- {
- fprintf(stderr, "Unable to open file `%s'\n", filename);
- exit(1);
- }
-
- if (!fgets(buff, sizeof(buff), fp))
- {
- perror(filename);
- exit(1);
- }
-
- if (buff[0] != 'P' || buff[1] != '6')
- {
- fprintf(stderr, "Invalid image format (must be `P6')\n");
- exit(1);
- }
-
- result = (PPMImage *) malloc(sizeof(PPMImage));
- if (!result)
- {
- fprintf(stderr, "Unable to allocate memory\n");
- exit(1);
- }
-
- if (fscanf(fp, "%d %d", &w, &h) != 2)
- {
- fprintf(stderr, "Error loading image `%s'\n", filename);
- exit(1);
- }
- result->sizeX = w;
- result->sizeY = h;
-
- if (fscanf(fp, "%d", &maxval) != 1)
- {
- fprintf(stderr, "Error loading image `%s'\n", filename);
- exit(1);
- }
-
- while (fgetc(fp) != '\n')
- ;
-
- result->data = (GLubyte *) malloc(3 * result->sizeX * result->sizeY);
- if (!result)
- {
- fprintf(stderr, "Unable to allocate memory\n");
- exit(1);
- }
-
- if (fread(result->data, 3 * result->sizeX, result->sizeY, fp) != result->sizeY)
- {
- fprintf(stderr, "Error loading image `%s'\n", filename);
- exit(1);
- }
-
- fclose(fp);
-
- return result;
-}
-