473,804 Members | 3,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

image reading

I want to know how to read image files in C.. what are the headers
that i should include? is there any tutorials regarding this ? pls
inform me.
Oct 6 '08 #1
36 2397
vi*******@gmail .com said:
I want to know how to read image files in C.. what are the headers
that i should include?
C doesn't directly support any particular image format (although one might
make out a case for XPM), but it's easy enough to open a file using fopen.
Then comes the fun part - working out which bit of the file means what.
is there any tutorials regarding this ?
http://www.wotsit.org has the specs on lots of file formats.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Oct 6 '08 #2
On Oct 6, 4:18 pm, vimal3...@gmail .com wrote:
I want to know how to read image files in C.. what are the headers
that i should include? is there any tutorials regarding this ?
You can open files with fopen. You can read their data with various
functions, for example, fgetc, fread.
The headers that should be included depend on the functions you are
going to use.
Any decent C book will help you with all these.
I recommend K&R2.
pls inform me.
pls? Don't you mean please? Type the whole word, please.
Oct 6 '08 #3
In article <5a************ *************** *******@c22g200 0prc.googlegrou ps.com>,
<vi*******@gmai l.comwrote:
>I want to know how to read image files in C.. what are the headers
that i should include? is there any tutorials regarding this ? pls
inform me.
You probably don't want to write this yourself. There are free
libraries available for the common formats like JPEG and TIFF, and
they should be fairly portable. Obviously displaying an image is
system-dependent, but just reading in the data is much less so.

Start by Googling for libjpeg, libtiff, libpng...

-- Richard
--
Please remember to mention me / in tapes you leave behind.
Oct 6 '08 #4
On Mon, 06 Oct 2008 06:18:32 -0700, vimal3271 wrote:
I want to know how to read image files in C.. what are the headers that
i should include? is there any tutorials regarding this ? pls inform me.
Simple:

libgd http://www.libgd.org

Powerful:

libvips http://vips.sf.net
Oct 6 '08 #5
vi******@gmail. com said:
On Oct 6, 4:18 pm, vimal3...@gmail .com wrote:
>I want to know how to read image files in C.. what are the headers
that i should include? is there any tutorials regarding this ?

You can open files with fopen. You can read their data with various
functions, for example, fgetc, fread.
The headers that should be included depend on the functions you are
going to use.
Any decent C book will help you with all these.
I recommend K&R2.
Perhaps you could remind me which section of K&R2 deals with image formats?

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Oct 6 '08 #6
On Oct 6, 6:20 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
vipps...@gmail. com said:
On Oct 6, 4:18 pm, vimal3...@gmail .com wrote:
I want to know how to read image files in C.. what are the headers
that i should include? is there any tutorials regarding this ?
You can open files with fopen. You can read their data with various
functions, for example, fgetc, fread.
The headers that should be included depend on the functions you are
going to use.
Any decent C book will help you with all these.
I recommend K&R2.

Perhaps you could remind me which section of K&R2 deals with image formats?
OP mentioned image files, image files are just files.
Oct 6 '08 #7
vi*******@gmail .com pisze:
I want to know how to read image files in C.. what are the headers
that i should include? is there any tutorials regarding this ? pls
inform me.
For me the simplest image file is PPM. If you can create file you can
also read it.

=============== ===
#include <stdio.h>
int main() {
const int dimx = 800;
const int dimy = 800;
int i, j;
FILE * fp = fopen("first.pp m", "wb"); /* b - tryb binarny */
fprintf(fp, "P6\n%d %d\n255\n", dimx, dimy);
for(j=0; j<dimy; ++j){
for(i=0; i<dimx; ++i){
static unsigned char color[3];
color[0]=i % 255; /* red */
color[1]=j % 255; /* green */
color[2]=(i*j) % 255; /* blue */
fwrite(color,1, 3,fp);
}
}
fclose(fp);
return 0;
}

=============== =============== ======
Look also :

http://fraktal.republika.pl/g_file.html
HTH

Adam
Oct 6 '08 #8
vi******@gmail. com said:
On Oct 6, 6:20 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
>vipps...@gmail .com said:
On Oct 6, 4:18 pm, vimal3...@gmail .com wrote:
I want to know how to read image files in C.. what are the headers
that i should include? is there any tutorials regarding this ?
You can open files with fopen. You can read their data with various
functions, for example, fgetc, fread.
The headers that should be included depend on the functions you are
going to use.
Any decent C book will help you with all these.
I recommend K&R2.

Perhaps you could remind me which section of K&R2 deals with image
formats?

OP mentioned image files, image files are just files.
On one level, yes, that's true - but if he just meant arbitrary files, he'd
have said so. He specifically mentioned image files, and it doesn't
require a genius to deduce that he wishes to do some kind of image
processing (even if it's only display), which means he's going to need to
be able to decode image formats. He realises this. I realise this. And I
suspect you realise this too. To pretend otherwise is disingenuous.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Oct 6 '08 #9
On Mon, 06 Oct 2008 06:18:32 -0700, vimal3271 wrote:
I want to know how to read image files in C.. what are the headers that
i should include? is there any tutorials regarding this ? pls inform me.
Well, it depends on which formats you need to open. Do you just want to
read the image files, or be able to display them.

You could try "Developer' s Image Library" and write code to use it.

http://directory.fsf.org/project/DevIL/

Or for more open source image libraries, you could look here.

http://directory.fsf.org/category/ilibs/

stonerfish
Oct 6 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4817
by: Weston C | last post by:
I'm new to the GD/Image functions with PHP, and I'm trying to use them to manipulate jpeg images that I've stored in a MySQL database (specifically, creating thumbnails). The thing I can't tell from reading the documentation is how to use these image functions to operate on image data -- it looks like you get a GD image resource in each case by specifying a file name, not by passing image data directly. While I can see how that's...
13
3739
by: PS | last post by:
I want to display the image from database to picture box through ado.net and vb.net I have some images present in a sql server 2000 table stored under 'image' datatype. I want to extract and display them in a picture box present in a vb.net form I appreciate any help on this Thanks PS
0
1335
by: Thomas | last post by:
Hi all, I'm in search of a fast solution to reading image dimensions. I know you can get the image dimensions by loading a file into an image object, and then reading the height/width properties, but this is really slow (relatively speaking). Another poster suggested I could read the image headers manually by streaming the first X number of bytes of the file, but this is fairly consuming approach and hoping there's another option.
3
2303
by: Steve Tooke | last post by:
I'm trying to find a way to quickly read image headers (specifically jpgs at the moment) with out loading the whole image as an System.Imaging.Image. Anybody point me in the right direction or am I going to need to write a header parser from scratch?
4
7627
by: Andy | last post by:
Hello All: I have a field in the database that is an Image. I have no idea how the data is stored in here (Image, compressed, encrypted, plain text, etc). I am trying to write the contents to a text file, image file, etc so I can see if the data is stored in a way we can understand (we have been tasked to write an app and the app needs to read this field, but we don't know what it really contains). How would I go about reading the...
3
3638
by: dale zhang | last post by:
Hi, I am trying to read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp The article author is using PictureBox for windows application, while I am doing for web. I can only find Image from web forms control and HTML control. This may be the root cause of my problem. For read button, I converted his VB to the C#. But the compiler complains:
4
3308
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any errors. After reading the ole object from db, I saved it to C: as file1.bmp and displayed on the web. But it can not be displayed. After I manually sent the file to wordpad, it shows
2
3757
by: Chucker | last post by:
Hi Community, I think I can store Binary Data in SQL Server but when I try to retrieve it, I always only get one byte. I think I stored my Binary Data in SQL Server in a Colum of Type Image. At least when I execute the following code, I get some significant network traffic. When I check the database with query analyzer, I see 4 Hex Chars in the image colum. Like 0xe0 etc.
3
5365
by: anewbie | last post by:
hi. ive been searching for help with storing images in access. after much hunting i found this bit of code that Cor Ligthert put up on another forum. but when i try to update to the dataset, i get this error: system.argument. exception in system.data.dll, cannot change data type of a column once it has data. for one thing my column is empty, for another, i get that message even when i select "upload to dataset" without first selecting...
2
7384
by: Ed | last post by:
Hope someone can help me out... I have been tasked to read some image data from an sql database and save the files to flat files. OK, sounds easy as I'v used BLOBs before. But this is an old database and I cannot get the image to work. The columns in the database are of type text. Here is one of the images text (in full) in the database (I hope you can see it):
0
9582
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10335
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9157
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7621
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2993
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.