473,327 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

How to convert image formats?

Hello Everyone,

I'm new to this place. Have a few doubts hoping to get some response
soon :)

1. How can i convert a color BMP file into a monochrome black and white
image (NOT GRAYSCALE) in C ???

2. Are there any routines available which can display images in my C
application?? I know CImg might help but it uses C++ :(

3. Also how can i call a program say for eg. notepad.exe from my
program?? i.e in my code how do i execute the program notepad.exe

I agree i have asked quite some doubts :P
but i am a newbie and I am working on my University project which need
me to do all these stuff. Having some problems with the above :)

I wud b very grateful if someone cud post a lil bit of sample code too
:P
Thank You!
Have fun!

Mar 30 '06 #1
5 4391
"aks1232001" <sr******@gmail.com> wrote:
1. How can i convert a color BMP file into a monochrome black and white
image (NOT GRAYSCALE) in C ???
a. You find the BMP file format on <http://www.wotsit.org/>.
b. You design an algorithm to convert colour information reliably into
black-and-white (NOT GRAYSCALE) information. This is probably going
to be the trickiest part of the job, by a considerable margin. It is
also not a C problem, but an algorithm problem.
c. You implement this algorithm in C.

The good news is: this is all possible in pure ISO C (all it does is
manipulate binary files), so once you _do_ have your file specs and
conversion algorithm and have made a serious attempt at doing your own
homework, any snags you encounter would quite possibly be on-topic in
comp.lang.c.
2. Are there any routines available which can display images in my C
application??
Undoubtedly, but they're all system-specific, and therefore off-topic
here. Even on a single OS it would depend on how and where you'd want to
display it. Ask in a newsgroup that discusses your particular compiler/
OS/graphhics lib.
3. Also how can i call a program say for eg. notepad.exe from my
program?? i.e in my code how do i execute the program notepad.exe
system("notepad.exe");
I agree i have asked quite some doubts :P
No, you haven't. You've asked some questions.
I wud b very grateful if someone cud post a lil bit of sample code too


So would I; but it's _your_ homework, so it's going to have to be you
who posts it.

It would also be a good idea if you
- wrote proper English, without schoolboy abbreviations such as "cud";
- got a dictionary ("doubt" does not mean what you think it does), and
while you're at it, educate your peers; this error is all too common;
- read the FAQ and Welcome message _before_ posting to a newsgroup, as
common (or these days, alas, all too uncommon) netiquette requires.

Richard
Mar 30 '06 #2
Thanx Richard!

I have taken note the things You suggested :)

I did do my homework a bit: heres the code i wrote and the error im
getting while using the bloodshed dev c++ compiler on windows XP

code::
#include <dos.h>
#include<stdio.h>
#include<conio.h>

int main()
{
clrscr();
printf("Hello!\nLets Hope the Program Executes :)");
getch();
system("C:\\notepad.exe");
getch();
return(0);

}
Error: system undeclared (first use this fuction)

when i declared the function system as const char* (as suggested by the
compiler) the program executed but the file notepad.exe did open :(

I did copy notepad.Exe to the C:\ directory also i tried various other
possibilities like

system("notepad.exe");
system("C:\notepad.exe");

but nothing is working

The same is the case in the Turbo C 3.0 compiler :(

Mar 30 '06 #3
oopsie..It is working now.. No probs.. Thanks for the Help :)

Edit: i started a new project in Dev C++ -> Windows Console Project->
in C language..

then wrote this code and it worked :)

Thanx for the help

by the way I am trying to use netpbm to slove the problem with image
loading etc
(found out abt it by digging through the archieves of this group :P)

Mar 30 '06 #4
"aks1232001" <sr******@gmail.com> wrote in message
news:11*********************@i39g2000cwa.googlegro ups.com...
Thanx Richard!

I have taken note the things You suggested :)

I did do my homework a bit: heres the code i wrote and the error im
getting while using the bloodshed dev c++ compiler on windows XP

code::
#include <dos.h>
#include<stdio.h>
#include<conio.h>

int main()
{
clrscr();
printf("Hello!\nLets Hope the Program Executes :)");
getch();
system("C:\\notepad.exe");
getch();
return(0);

}
Error: system undeclared (first use this fuction)


You should always quote context in your replies or you will be shouted at in
this group. Your program is far too complicated and contains many
non-standard features. Try the following which is still implementation
specific:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
printf("Trying to open notepad.exe\n");
system("notepad.exe");
return 0;
}
Mar 30 '06 #5
"aks1232001" <sr******@gmail.com> wrote:
# Hello Everyone,
#
# I'm new to this place. Have a few doubts hoping to get some response
# soon :)
#
# 1. How can i convert a color BMP file into a monochrome black and white
# image (NOT GRAYSCALE) in C ???

Image processing tends to vary widely on different systems. Some
like MacOSX have a lot of processing builtin; others like Linux
have downloadable libraries like image magick.

# 2. Are there any routines available which can display images in my C
# application?? I know CImg might help but it uses C++ :(

Depends on your system. X-Windows, Aqua, and presumably Windows
have incompatiable methods. Scripting languages like Tcl/Tk can
can do this with more platform independence than C.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
I have no respect for people with no shopping agenda.
Mar 31 '06 #6

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

Similar topics

4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
0
by: Andreas Håkansson | last post by:
Hiya! I'm currently looking for a good image processig component (classes) to use in a project. I do not want to controls (winform or webform) since I will be doing this with code. I actually...
6
by: Jensen bredal | last post by:
Hello gurus I need to upload to accept image upload on my site. I also need to display these images in a databound control. The image are upload in a database. My concers are: -How do i...
2
by: Kenneth Keeley | last post by:
Hi, I am creating a news and events page on my Intranet site and I wish to allow people to upload an image with there news to my site. The text and image are all stored in an SQL database. I have...
8
by: Christopher Kurtis Koeber | last post by:
Dear All, Recently I created a thread about trying to load a particular ICON image that GDI plus could not load. I realized that GDI plus definitely does not support it because it had a certain...
8
by: platinumhimani | last post by:
-How to convert any image(8,16,24,32 or 64-bit) to 8-bit grayscale -i have tried to convert a 24-bit image to grayscale using setpixel and getpixel functions, in vb.net but i am unable to save...
1
by: info | last post by:
For fingerprint images WSQ (Wavelet Scalar Quantization) is superior to other lossy compression methods, such as JPEG, and was chosen by FBI (U.S. Federal Bureau of Investigation) as the...
2
by: Peter Oliphant | last post by:
The Image class allows loading a bitmap from a graphic file. So far I've gotten it to work with JPG and BMP files. What other graphic file formats are supported in this way? Is this fixed based...
36
by: vimal3271 | last post by:
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.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.