LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-10-2004, 11:21 PM   #1
chaits
LQ Newbie
 
Registered: Feb 2004
Location: Calicut
Posts: 10

Rep: Reputation: 0
Question reading a .jpg file in a C program...what to use?


Dear all,
i know it's really silly of me to ask this question here...but still let me ask it.
i want to read a .jpg file in a C program using the usual file-programming ways.
do i have to open the file n binary mode? if yes, which function shall i use? (fread, fprintf or anything else?)
if i want to manually copy a .jpg file, by OPENing it using open system call, then reading it's contents in a buffer using read system call & then writing them to another file using write system call; what should be the data type of buffer? will char array do??
i want something that will work for all types of files.... .jpg, .zip, .ps , .mp3, .. all... which functions, which file opening modes should i use??
i am not a novice C programmer. i am a student & i am using C since last 3 years. it's just the case that this particular thing is not working......will anybody help me please???
 
Old 03-11-2004, 12:38 AM   #2
urzumph
Member
 
Registered: Jan 2004
Location: Australia
Distribution: Debian
Posts: 168

Rep: Reputation: 30
usually one uses an array of int to store binary data. If you are looking to copy the file, perhaps you should just use a system call?
If that is not an option (perhaps being cross-platform is ultra-important?) then it's probably easiest to read one byte at a time. (Plus less memory usage)
 
Old 03-11-2004, 02:07 AM   #3
chaits
LQ Newbie
 
Registered: Feb 2004
Location: Calicut
Posts: 10

Original Poster
Rep: Reputation: 0
sorry to say, but i tried using a int buffer with open, read, write system calls. it doesn't work.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
c program reading file question blackzone Programming 1 11-19-2004 03:50 AM
Program to edit Meta-Info of jpg files phase9 Linux - Software 2 08-03-2004 01:42 AM
Gimp - jpg - unknown file type Wynd Linux - Software 1 06-27-2004 11:10 PM
whats a good program to read jpg files? :) sirpelidor Linux - Software 5 03-12-2004 03:42 AM
How to export graph as JPG file in Gnuplot ninja Linux - Software 1 05-30-2003 09:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration