IT Community - Software Programming, Web Development and Technical Support

How to load Image in C,CPP

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, ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C and C++ Programming

Register FAQ Members List Calendar Mark Forums Read
  #1  
Old 04-03-2008, 03:04 AM
seesamjagan seesamjagan is offline
D-Web Programmer
 
Join Date: Aug 2007
Location: Chennai
Posts: 66
seesamjagan is on a distinguished road
Send a message via AIM to seesamjagan Send a message via Yahoo to seesamjagan
Question How to load Image in C,CPP

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....
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 07-31-2008, 08:59 PM
DangerDev DangerDev is offline
D-Web Trainee
 
Join Date: Jul 2008
Location: Bangalore, India
Posts: 2
DangerDev is on a distinguished road
Default Re: How to load Image in C,CPP

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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 08-01-2008, 12:22 AM
seesamjagan seesamjagan is offline
D-Web Programmer
 
Join Date: Aug 2007
Location: Chennai
Posts: 66
seesamjagan is on a distinguished road
Send a message via AIM to seesamjagan Send a message via Yahoo to seesamjagan
Default Re: How to load Image in C,CPP

Quote:
Originally Posted by DangerDev View Post
hi,
which editor you are using?
hi
I'm using Turbo CPP editor.
__________________
SeeSamJagan
- Sky is not the "LIMIT", Death is not the END, There is still something beyond....
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4  
Old 12-23-2008, 07:25 PM
hkp819 hkp819 is offline
D-Web Trainee
 
Join Date: Dec 2008
Posts: 41
hkp819 is on a distinguished road
Default Re: How to load Image in C,CPP

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;

}
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

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


All times are GMT -7. The time now is 03:20 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0