Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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

Status
Not open for further replies.

nikhat_ahir

Newbie level 4
Newbie level 4
Joined
Mar 17, 2008
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
india
Visit site
Activity points
1,370
c++ display image

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.
 

display image 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.
 

    V

    Points: 2
    Helpful Answer Positive Rating
c++ show image

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.
 

display image in c++

nikhat_ahir said:
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!!!!
 

c++ image display

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.
 

c display image

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

**broken link removed**

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.
 

how to display image in 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.
 

c++ display picture

**broken link removed** is not a effective link
 

display image in 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.
 

c++ display graphics

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

yes it is!

Added after 6 minutes:

nikhat_ahir said:
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.
 

how to display an image in 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.
 

display images in 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.
 

how to display graphics in c++

You can use OpenGL library functions for this purpose....
 

show image 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.
 

display images in c

hi nikhat_ahir,

can you please write here your program with your solution?
 

display image using 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++
 

displaying images in c++

Hi nikhat_ahir..

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

display images c++

hi, its very easy, use the pointer address, for bmp read and directly write to grapichs card dac input.
 

Hi nikhat_ahir

yes u r right.. bitmap images can b displayed in C n no new graphics library or anything more is required.. but i want to ask u if u hav displayed an image of more than 16 bit colors... if so den plz let me know how u did it.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top