IMG_png.c
changeset 431 be8d5de840cc
parent 430 4c73e89f2551
child 451 48116d511e5d
equal deleted inserted replaced
430:4c73e89f2551 431:be8d5de840cc
   616 #endif
   616 #endif
   617         size_t size;
   617         size_t size;
   618         void *png = NULL;
   618         void *png = NULL;
   619 
   619 
   620         if (surface->format->format == png_format) {
   620         if (surface->format->format == png_format) {
   621             png = tdefl_write_image_to_png_file_in_memory(surface->pixels, surface->w, surface->h, surface->pitch, surface->format->BytesPerPixel, &size);
   621             png = tdefl_write_image_to_png_file_in_memory(surface->pixels, surface->w, surface->h, surface->format->BytesPerPixel, surface->pitch, &size);
   622         } else {
   622         } else {
   623             SDL_Surface *cvt = SDL_ConvertSurfaceFormat(surface, png_format, 0);
   623             SDL_Surface *cvt = SDL_ConvertSurfaceFormat(surface, png_format, 0);
   624             if (cvt) {
   624             if (cvt) {
   625                 png = tdefl_write_image_to_png_file_in_memory(cvt->pixels, cvt->w, cvt->h, cvt->pitch, cvt->format->BytesPerPixel, &size);
   625                 png = tdefl_write_image_to_png_file_in_memory(cvt->pixels, cvt->w, cvt->h, cvt->format->BytesPerPixel, cvt->pitch, &size);
   626                 SDL_FreeSurface(cvt);
   626                 SDL_FreeSurface(cvt);
   627             }
   627             }
   628         }
   628         }
   629         if (png) {
   629         if (png) {
   630             if (SDL_RWwrite(dst, png, size, 1)) {
   630             if (SDL_RWwrite(dst, png, size, 1)) {