~ubuntu-branches/ubuntu/lucid/boinc/lucid

« back to all changes in this revision

Viewing changes to api/texture.C

  • Committer: Bazaar Package Importer
  • Author(s): Frank S. Thomas, Frank S. Thomas
  • Date: 2008-05-31 08:02:47 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20080531080247-4ce890lp2rc768cr
Tags: 6.2.7-1
[ Frank S. Thomas ]
* New upstream release.
  - BOINC Manager: Redraw disk usage charts immediately after connecting to
    a (different) client. (closes: 463823)
* debian/copyright:
  - Added the instructions from debian/README.Debian-source about how
    repackaged BOINC tarballs can be reproduced because DevRef now
    recommends to put this here instead of in the afore-mentioned file.
  - Updated for the new release.
* Removed the obsolete debian/README.Debian-source.
* For consistency upstream renamed the core client and the command tool
  ("boinc_client" to "boinc" and "boinc_cmd" to "boinccmd"). Done the same
  in all packages and created symlinks with the old names for the binaries
  and man pages. Also added an entry in debian/boinc-client.NEWS explaining
  this change.
* debian/rules: Do not list Makefile.ins in the clean target individually,
  just remove all that can be found.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
1
2
#include <stdio.h>
2
3
#include <stdlib.h> 
3
4
#include <string.h>
110
111
    }
111
112
    image = (ImageRec *)malloc(sizeof(ImageRec));
112
113
    if (image == NULL) {
113
 
                fprintf(stderr, "Out of memory!\n");
114
 
                return NULL;
 
114
                goto error;
115
115
    }
116
116
    if ((image->file = fopen(fileName, "rb")) == NULL) {
117
117
                perror(fileName);
 
118
        free(image);
118
119
                return NULL;
119
120
    }
120
121
    fread(image, 1, 12, image->file);
127
128
    image->tmpG = (unsigned char *)malloc(image->xsize*256);
128
129
    image->tmpB = (unsigned char *)malloc(image->xsize*256);
129
130
    if (image->tmp == NULL || image->tmpR == NULL || image->tmpG == NULL ||image->tmpB == NULL) {
130
 
                fprintf(stderr, "Out of memory!\n");
131
 
                return NULL;
 
131
        goto error;
132
132
    }
133
133
 
134
134
    if ((image->type & 0xFF00) == 0x0100) {
136
136
                image->rowStart = (unsigned *)malloc(x);
137
137
                image->rowSize = (int *)malloc(x);
138
138
                if (image->rowStart == NULL || image->rowSize == NULL) {
139
 
                        fprintf(stderr, "Out of memory!\n");
140
 
                        return NULL;
 
139
            goto error;
141
140
                }
142
141
                image->rleEnd = 512 + (2 * x);
143
142
                fseek(image->file, 512, SEEK_SET);
149
148
                }
150
149
    }
151
150
    return image;
 
151
error:
 
152
    if (image) { 
 
153
        if (image->rowSize) free(image->rowSize); 
 
154
        if (image->rowStart) free(image->rowStart); 
 
155
        if (image->tmpB) free(image->tmpB); 
 
156
        if (image->tmpG) free(image->tmpG); 
 
157
        if (image->tmpR)free(image->tmpR); 
 
158
        if (image->tmp) free(image->tmp); 
 
159
        if (image->file) fclose(image->file); 
 
160
        free(image); 
 
161
    } 
 
162
    fprintf(stderr, "Out of memory!\n"); 
 
163
    return NULL; 
152
164
}
153
165
 
154
166
static void ImageClose(ImageRec *image) {
213
225
 
214
226
unsigned int texFormat;
215
227
 
216
 
unsigned char* getRGBA (FILE *s, int size){
 
228
unsigned char* getRGBA (FILE *s, size_t size){
217
229
    unsigned char *rgba;
218
230
    unsigned char temp;
219
 
    int bread;
220
 
    int i;
 
231
    size_t bread;
 
232
    size_t i;
221
233
    rgba=(unsigned char*)malloc(size * 4); 
222
234
    if (rgba == NULL) return 0;
223
235
    bread = fread (rgba, sizeof (unsigned char), size * 4, s); 
239
251
//      getRGB
240
252
//      Reads in RGB data for a 24bit image. 
241
253
//      =============
242
 
unsigned char* getRGB (FILE *s, int size){
 
254
unsigned char* getRGB (FILE *s, size_t size){
243
255
    unsigned char *rgb;
244
256
    unsigned char temp;
245
 
    int bread;
246
 
    int i;
 
257
    size_t bread;
 
258
    size_t i;
247
259
    rgb=(unsigned char*)malloc(size * 3); 
248
260
    if (rgb == NULL) return 0;
249
261
    bread = fread (rgb, sizeof (unsigned char), size * 3, s);
265
277
//      getGray
266
278
//      Gets the grayscale image data.  Used as an alpha channel.
267
279
//      =============
268
 
unsigned char* getGray (FILE *s, int size){
 
280
unsigned char* getGray (FILE *s, size_t size){
269
281
    unsigned char *grayData;
270
 
    int bread;
 
282
    size_t bread;
271
283
    grayData=(unsigned char*)malloc (size);
272
284
    if (grayData == NULL) return 0;
273
285
    bread = fread (grayData, sizeof (unsigned char), size, s);
332
344
    gbuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char));
333
345
    bbuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char));
334
346
    abuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char));
335
 
    if(!base || !rbuf || !gbuf || !bbuf) return NULL;
 
347
    if(!base || !rbuf || !gbuf || !bbuf) goto error;
336
348
    lptr = base;
337
349
        for(y=0; y<image->ysize; y++) {
338
350
                if(image->zsize>=4) {
365
377
    free(bbuf);
366
378
    free(abuf);
367
379
    return (unsigned *) base;
 
380
error:
 
381
        ImageClose(image); 
 
382
        if (abuf) free(abuf); 
 
383
        if (bbuf) free(bbuf); 
 
384
        if (bbuf) free(gbuf); 
 
385
        if (bbuf) free(rbuf); 
 
386
        if (base) free(base); 
 
387
        return NULL; 
368
388
}
369
389
 
370
 
const char *BOINC_RCSID_97d4f29d84="$Id: texture.C 12705 2007-05-21 18:19:28Z davea $";
 
390
const char *BOINC_RCSID_97d4f29d84="$Id: texture.C 13282 2007-08-10 01:51:14Z boincadm $";