diff options
author | Harry Jeffery <harry@exec64.co.uk> | 2015-11-06 14:38:13 +0000 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2015-11-06 14:38:13 +0000 |
commit | 6792180fc77697a0788a7fbf5d9b2e3cc81333c3 (patch) | |
tree | 5d8a885f6e57132539753436f1b53d96836ac42c | |
parent | 196d10737f547db6948c9a5d7200c8dfb59df624 (diff) | |
download | imv-6792180fc77697a0788a7fbf5d9b2e3cc81333c3.tar.gz |
Remove disused files
-rw-r--r-- | jpeg.c | 42 | ||||
-rw-r--r-- | png.c | 50 | ||||
-rw-r--r-- | tiff.c | 26 |
3 files changed, 0 insertions, 118 deletions
@@ -1,42 +0,0 @@ -#include <SDL2/SDL.h> -#include <string.h> -#include <jpeglib.h> -#include <setjmp.h> - -SDL_Texture* imv_load_jpeg(SDL_Renderer *r, const char* path) -{ - FILE *fp = fopen(path, "rb"); - if(!fp) { - return NULL; - } - - struct jpeg_decompress_struct cinfo; - jpeg_create_decompress(&cinfo); - struct jpeg_error_mgr jerr; - cinfo.err = jpeg_std_error(&jerr); - - jpeg_stdio_src(&cinfo, fp); - jpeg_read_header(&cinfo, TRUE); - jpeg_start_decompress(&cinfo); - int row_stride = cinfo.output_width * cinfo.output_components; - JSAMPARRAY buffer = (*cinfo.mem->alloc_sarray) - ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); - char* pixels = (char*)malloc(row_stride*cinfo.output_height); - while (cinfo.output_scanline < cinfo.output_height) { - jpeg_read_scanlines(&cinfo, buffer, 1); - void *out_row = pixels + row_stride * (cinfo.output_scanline-1); - memcpy(out_row, buffer[0], row_stride); - } - jpeg_finish_decompress(&cinfo); - jpeg_destroy_decompress(&cinfo); - fclose(fp); - - SDL_Texture *img = SDL_CreateTexture(r, - SDL_PIXELFORMAT_RGB24, SDL_TEXTUREACCESS_STATIC, - cinfo.output_width, cinfo.output_height); - - SDL_Rect area = {0,0,cinfo.output_width,cinfo.output_height}; - SDL_UpdateTexture(img, &area, pixels, row_stride); - free(pixels); - return img; -} @@ -1,50 +0,0 @@ -#include <SDL2/SDL.h> -#include <string.h> -#include <png.h> - -SDL_Texture* imv_load_png(SDL_Renderer *r, const char* path) -{ - FILE *fp = fopen(path, "rb"); - - if(!fp) { - return NULL; - } - - png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if(!png) { - fclose(fp); - return NULL; - } - - png_infop info = png_create_info_struct(png); - if(!info) { - fclose(fp); - png_destroy_read_struct(&png, NULL, NULL); - return NULL; - } - - png_init_io(png, fp); - png_read_png(png, info, - PNG_TRANSFORM_STRIP_16 | PNG_TRANSFORM_PACKING | PNG_TRANSFORM_EXPAND, - NULL); - png_uint_32 width, height; - png_get_IHDR(png, info, &width, &height, NULL, NULL, NULL, NULL, NULL); - unsigned int bytes_per_row = png_get_rowbytes(png, info); - png_bytepp row_ptrs = png_get_rows(png, info); - - char* pixels = (char*)malloc(bytes_per_row*height); - for (unsigned int i = 0; i < height; i++) { - memcpy(pixels + bytes_per_row * i, row_ptrs[i], bytes_per_row); - } - png_destroy_read_struct(&png, &info, NULL); - fclose(fp); - - SDL_Texture *img = SDL_CreateTexture(r, - SDL_PIXELFORMAT_RGB24, SDL_TEXTUREACCESS_STATIC, - width, height); - - SDL_Rect area = {0,0,width,height}; - SDL_UpdateTexture(img, &area, pixels, bytes_per_row); - free(pixels); - return img; -} @@ -1,26 +0,0 @@ -#include <SDL2/SDL.h> -#include <tiffio.h> - -SDL_Texture* imv_load_tiff(SDL_Renderer *r, const char* path) -{ - TIFF* tif = TIFFOpen(path, "r"); - if(!tif) { - return NULL; - } - SDL_Texture *img = NULL; - uint32 w, h; - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); - size_t npixels = w * h; - uint32 *pixels = (uint32*) malloc(npixels * sizeof (uint32)); - if (TIFFReadRGBAImageOriented(tif, w, h, pixels, ORIENTATION_TOPLEFT, 0)) { - img = SDL_CreateTexture(r, - SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STATIC, w, h); - SDL_Rect area = {0,0,w,h}; - SDL_UpdateTexture(img, &area, pixels, sizeof(uint32) * w); - } - free(pixels); - TIFFClose(tif); - return img; -} - |