This is a discussion on How to load Image in C,CPP within the C and C++ Programming forums, part of the Software Development category; Hi, i would like to do some graphics application with C, where i need to load external images(JPEG, GIG, ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| Hi, i would like to do some graphics application with C, where i need to load external images(JPEG, GIG, BMP) into the application. how can i load the images into may C application. thanks in advance
__________________ SeeSamJagan- Sky is not the "LIMIT", Death is not the END, There is still something beyond.... |
|
#2
| |||
| |||
| hi, which editor you are using?
__________________ Rushing to work... Rushing to college... Line for movie... Tension for school... Same traffic... Same Life ... No Terror, No Panic. Terror Traders Defeated. We Are Bangalore. |
|
#3
| |||
| |||
| hi I'm using Turbo CPP editor.
__________________ SeeSamJagan- Sky is not the "LIMIT", Death is not the END, There is still something beyond.... |
|
#4
| |||
| |||
| I thinks below coding will help you:-- #include <string.h> #include <stdio.h> #include <stdlib.h> #include "loadimage.h" #include "types.h" extern char* uppercase(char* str); // -------------------------------------------------------- // PNG // -------------------------------------------------------- bool LoadPNG(Image* image, char* filename) { return false; } // -------------------------------------------------------- // JPG // -------------------------------------------------------- bool LoadJPG(Image* image, char* filename) { return false; } // -------------------------------------------------------- // TIFF // -------------------------------------------------------- bool LoadTIFF(Image* image, char* filename) { return false; } // -------------------------------------------------------- // Generic // -------------------------------------------------------- char* SupportedFormats[] = {"BMP"}; /* ,"JPEG", "PNG", "TIFF"}; */ uint32 NumSupportedFormats = 1; char* GetSupportedFormats() { static char str[64]; sprintf(str,"%s", SupportedFormats[0]); for(uint32 i=1; i < NumSupportedFormats; i++) { sprintf(str, "%s, %s", str, SupportedFormats[i]); } return str; } bool LoadImage(Image* image, char* filename) { char ext[32]; image->data = 0; image->width = 0; image->height = 0; uint32 i = strlen(filename); while(i > 0) { if(filename[i] == '.') { strcpy(ext, &filename[i+1]); break; } i--; } if(!strcasecmp(ext, "BMP")) return LoadBMP(image, filename); // if(!strcasecmp(ext, "JPG") || !strcasecmp(ext, "JPEG")) return LoadJPG(image, filename); if(!strcasecmp(ext, "PNG")) return LoadPNG(image, filename); // if(!strcasecmp(ext, "TIF") || !strcasecmp(ext, "TIFF") ) return LoadTIFF(image, filename); if(i) printf("Error: Image type %s not supported\n", uppercase(ext)); else printf("Error: '%s' has no extension\n", filename); return false; } bool FreeImage(Image* image) { dprintf("freeimage\n"); if(image->data) free(image->data); image->width = 0; image->height = 0; } |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Convert image to other image format using CODEC in .NET 3.0 | Mramesh | C# Programming | 0 | 02-07-2008 02:33 AM |
| How to create an image from panel background Image | S.Vinothkumar | C# Programming | 1 | 10-22-2007 02:52 AM |
| What is the use of Load Analyser in load runner? | sundarraja | Testing Tools | 1 | 09-14-2007 07:10 AM |
| How do you load GUI map? | Shanthi | Testing Tools | 1 | 08-10-2007 04:57 AM |
| How to load the image in webpage using xml script? | Archer | HTML, CSS and Javascript Coding Techniques | 1 | 07-19-2007 11:27 PM |
Our Partners |