How to convert image formats?

Discussion in 'C Programming' started by aks1232001, Mar 30, 2006.

  1. aks1232001

    aks1232001 Guest

    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!
     
    aks1232001, Mar 30, 2006
    #1
    1. Advertising

  2. aks1232001

    Richard Bos Guest

    "aks1232001" <> 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
     
    Richard Bos, Mar 30, 2006
    #2
    1. Advertising

  3. aks1232001

    aks1232001 Guest

    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 :(
     
    aks1232001, Mar 30, 2006
    #3
  4. aks1232001

    aks1232001 Guest

    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)
     
    aks1232001, Mar 30, 2006
    #4
  5. "aks1232001" <> wrote in message
    news:...
    > 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;
    }
     
    stathis gotsis, Mar 30, 2006
    #5
  6. aks1232001

    SM Ryan Guest

    "aks1232001" <> 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.
     
    SM Ryan, Mar 31, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. unni
    Replies:
    0
    Views:
    409
  2. Matt
    Replies:
    1
    Views:
    364
    Martin Honnen
    Jul 5, 2004
  3. MostafaSayed

    Help in coverting image formats

    MostafaSayed, Jun 25, 2007, in forum: .NET
    Replies:
    0
    Views:
    351
    MostafaSayed
    Jun 25, 2007
  4. Jim Mitten
    Replies:
    3
    Views:
    430
    Joseph Kesselman
    Jan 29, 2008
  5. Richard Hollenbeck

    convert multiple date formats and compare those dates

    Richard Hollenbeck, Feb 11, 2004, in forum: Javascript
    Replies:
    4
    Views:
    168
    Dr John Stockton
    Feb 12, 2004
Loading...

Share This Page