Rules | Recent posts | topic RSS | Search | Register  | Log in

how to display an image using C or C++?

 
Post new topic  Reply to topic    EDAboard.com Forum Index -> Digital Signal Processing
Author Message
nikhat_ahir



Joined: 17 Mar 2008
Posts: 8
Location: india


Post01 Apr 2008 17:46   how to display an image using C or C++?

i want to display bitmap image using c or c++.
i m getting problem with putpixel(x,y,color) function, as it takes only upto 15 for color argument.
is there any other way to display image in C or C++?
waiting for kind replies.

thanks, and regards,
nikhat ahir.
Back to top
Old Nick



Joined: 14 Sep 2007
Posts: 409
Helped: 49


Post01 Apr 2008 18:18   Re: how to display an image using C or C++?

You're using the graphics.h library which is from the 80's. So as far as I know you're stuck with those colours.

You have a couple of options, neither of which are particularly easy. You can use visual c, and create a Windows program, then you have rgb(255,255,255) colours. But if you've never programmed in visual C then there is a pretty steep learning curve.
The other option is to use the allegro graphics library (I've never used this, so I can't comment too much on it), which is freely downloadable and is supposedly not to complex. You could also try dirextX, but I believe it is much more complex.
Back to top
nikhat_ahir



Joined: 17 Mar 2008
Posts: 8
Location: india


Post01 Apr 2008 18:40   how to display an image using C or C++?

hi,
thanks for suggestion. but, i need to display image using C or C++ code only.
i know vc, java, and even better for image processing, i also know matlab.
but, i need to display image in C or C++.
is there any way to put pixels having color greater than 16, such as 256 color (8-bit) image.
waiting for replies.

thanks, and regards,
nikhat ahir.
Back to top
Old Nick



Joined: 14 Sep 2007
Posts: 409
Helped: 49


Post01 Apr 2008 18:47   Re: how to display an image using C or C++?

nikhat_ahir wrote:
hi,
thanks for suggestion. but, i need to display image using C or C++ code only.
i know vc, java, and even better for image processing, i also know matlab.
but, i need to display image in C or C++.
is there any way to put pixels having color greater than 16, such as 256 color (8-bit) image.
waiting for replies.

thanks, and regards,
nikhat ahir.


And that's exactly what I've told you to do!!!!
Back to top
nikhat_ahir



Joined: 17 Mar 2008
Posts: 8
Location: india


Post01 Apr 2008 19:11   how to display an image using C or C++?

man, my requirement is to display image in C or C++. else, u wouldnt have this question.
do u know how to display this one?
if not, its ok.
i m trying. and, i vl display it in C/C++. i m confident for it. okay?

thanks,
nikhat ahir.
Back to top
Old Nick



Joined: 14 Sep 2007
Posts: 409
Helped: 49


Post01 Apr 2008 19:29   Re: how to display an image using C or C++?

man, yes I do know how to do it, and I've already told you how to. And I don't appreciate your patronising tone, when I've answered your question. You may not like the answer, but it is the answer none the less.

you are using the graphics.h library which is an old borland c library. That library is a relic from the 80's hence it's limited colour capabilities.

But to create a console app with some graphics it was OK in it's day.
To do what you want you have to either program 'IN C' for a target that has graphics functionality, which DOS does not!, and program for Windows using Windows own functions.
Or you could, as I've already said, download a more modern graphics library for "C/C++", and use the functions in it, such as the Allegro library, which can be found here

http://www.talula.demon.co.uk/allegro/

and is for C/C++

Everything I've suggested is using C/C++!!!

Bythe way, putpixel(x,y,color) is not ANSI C.

You can still use this function using the winbgi version of the library, but again you're going to have to target windows with your program.
Back to top
echo47



Joined: 07 Apr 2002
Posts: 4206
Helped: 565


Post01 Apr 2008 21:54   how to display an image using C or C++?

Let's all try to be friendly here!

Hi nikhat_ahir, Which compiler and operating system are you using? Sixteen-color putpixel() sounds like old Turbo C and DOS.

The standard C and C++ languages don't have any built-in support for graphic. Graphics features are usually added to the compiler through special function libraries or calls into the operating system, and those techniques differ depending on your particular compiler and operating system.
Back to top
calm



Joined: 17 Oct 2005
Posts: 268
Helped: 5


Post02 Apr 2008 3:24   how to display an image using C or C++?

http://www.talula.demon.co.uk/allegro/ is not a effective link
Back to top
nikhat_ahir



Joined: 17 Mar 2008
Posts: 8
Location: india


Post08 Apr 2008 18:20   how to display an image using C or C++?

hi to all,
spcially old nick,
thanks for ur suggestions, but i have a news for u all.
i displayed a bmp image using C language. no need of any advanced libraries for graphics support.
again, thanks for ur supports, i got my problem solved.

bye,
nikhat ahir.
Back to top
Old Nick



Joined: 14 Sep 2007
Posts: 409
Helped: 49


Post08 Apr 2008 19:37   Re: how to display an image using C or C++?

calm wrote:
http://www.talula.demon.co.uk/allegro/ is not a effective link


yes it is!

Added after 6 minutes:

nikhat_ahir wrote:
hi to all,
spcially old nick,
thanks for ur suggestions, but i have a news for u all.
i displayed a bmp image using C language. no need of any advanced libraries for graphics support.
again, thanks for ur supports, i got my problem solved.

bye,
nikhat ahir.


You were asking for help with putpixel, wanting to display more than 16 colours. For that you needed to use a library more modern than the old borland graphics.h one.
You now have solved your problenm by loading a bitmap image. For this you wiull have had to use a library exactly the same as you would have for using a putpixel(). They are both utilising C language, which you seem to have some difficulty distinguishing.
You should try and think about your questions more carefully in future as the solution you have told us about is not a solution to the question you asked in your first posts.
Back to top
nikhat_ahir



Joined: 17 Mar 2008
Posts: 8
Location: india


Post08 Apr 2008 21:19   Re: how to display an image using C or C++?

hi,
my question was:
"i want to display bitmap image using c or c++.
i m getting problem with putpixel(x,y,color) function, as it takes only upto 15 for color argument.
is there any other way to display image in C or C++?....."

so, where did i tell that i want to display image using putpixel only? i had asked about any other possible way.
and one of the possible way is to use "pointer". u can display image using pointer. u even do not need do use putpixel, nor u need graphics.h, standard one or modern one, nor u need any advance functions.

i was clear with my question. and, now clear with my answer. i can display image using pointer in C. i even do not need to use java, matlab, vc or some thing else, nor i need to use any advance library.

so, please, dont get me wrong, my friend. because, i cant put my question in a better way than i did. if u know any better way, ur most welcome.

again, thanks,
nikhat ahir.
Back to top
echo47



Joined: 07 Apr 2002
Posts: 4206
Helped: 565


Post09 Apr 2008 3:50   how to display an image using C or C++?

The standard C language does not have any graphics functions. Your graphics functions (such as putpixel) are probably located in a special graphics library that was bundled with your compiler. That library knows how to directly access the graphics controller, or how to call the operating system or device driver to do drawing functions.

It's difficult to answer your original question without knowing which compiler and operating system you are using. If it's an old environment such as DOS, then graphics display methods may depend on the type of graphics card you've installed.
Back to top
rag.perfect



Joined: 29 Oct 2007
Posts: 41
Helped: 6


Post09 Apr 2008 5:44   Re: how to display an image using C or C++?

You can use OpenGL library functions for this purpose....
Back to top
mmelek1



Joined: 20 Apr 2002
Posts: 125
Helped: 3


Post10 Apr 2008 19:51   how to display an image using C or C++?

You can use opencv which is a free graphics library.
You can get it from:
http://sourceforge.net/projects/opencvlibrary/
Back to top
nikhat_ahir



Joined: 17 Mar 2008
Posts: 8
Location: india


Post12 Apr 2008 19:29   how to display an image using C or C++?

hi,
no need of using opencv or openGL or anything else. i got solution using POINTER only.
if i have to use OpenGL, then there r many alternatives, like as vc, java... and the most convenient way, as per me, is to use Matlab. but, my problem is different one.
but, now, it has been solved.

again thanks to u all,
nikhat ahir.
Back to top
milonim



Joined: 05 Aug 2008
Posts: 1


Post05 Aug 2008 20:42   Re: how to display an image using C or C++?

hi nikhat_ahir,

can you please write here your program with your solution?
Back to top
bhq



Joined: 11 Jun 2008
Posts: 81
Helped: 7


Post16 Aug 2008 10:12   Re: how to display an image using C or C++?

plz use the command in MATLAB imread() to read the image from work directory. and imshow() to show or display the image.

I think MATLAB is more handy with doing Image Processing and filtering in both spacial and frequency domain.
It has similar symtax as C or C++
Back to top
astha.aggarwal



Joined: 07 Oct 2008
Posts: 1


Post07 Oct 2008 9:22   Re: how to display an image using C or C++?

Hi nikhat_ahir..

Will u please paste ur code here. I m eager to knw hw u did that by using pointers.
Back to top
karikalan_t79



Joined: 20 Oct 2008
Posts: 99
Helped: 1


Post23 Oct 2008 1:08   Re: how to display an image using C or C++?

hi, its very easy, use the pointer address, for bmp read and directly write to grapichs card dac input.
Back to top
Post new topic  Reply to topic    EDAboard.com Forum Index -> Digital Signal Processing
Page 1 of 1 All times are GMT + 1 Hour


Abuse
Administrator
Moderators
topic RSS 
sitemap