LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   C: minimalist displaying an image file to pixels ? (https://www.linuxquestions.org/questions/programming-9/c-minimalist-displaying-an-image-file-to-pixels-4175469877/)

Xeratul 07-16-2013 10:21 PM

C: minimalist displaying an image file to pixels ?
 
Hi,

I have been trying to convert a jpg to various format (gimp), then
to import them into C program, but those formats are likely difficult to process. (without using libs of imagemagick)

mbm is quite simple but actually ... not so much.

Would you know how to convert a bitmap (whatever format) to a RESIZABLE pixel array?

I wish direction shall I start? (without using libs of imagemagick)

int row, cols; //for my screen/image max size

Cheers,
Thanks

BenCollver 07-16-2013 11:20 PM

NetPBM
 
Here is an example that uses NetPBM [1] to make an easily readable ASCII version of the image.

Code:

anytopnm foobar.jpg 2>/dev/null | pnmnoraw >foobar.ppm
[1]
http://en.wikipedia.org/wiki/Netpbm_format

Xeratul 07-16-2013 11:45 PM

Quote:

Originally Posted by BenCollver (Post 4991686)
Here is an example that uses NetPBM [1] to make an easily readable ASCII version of the image.

Code:

anytopnm foobar.jpg 2>/dev/null | pnmnoraw >foobar.ppm
[1]
http://en.wikipedia.org/wiki/Netpbm_format

for that it is not so much cross-platform,... although the lib netpbm is on windows, but on windows you would need cigwin

Xeratul 07-17-2013 10:43 PM

actually, I might find a way... somehow to get the array on int filled



a question, to resize my array, which method might be advised?


ex:
I have a bitmap for a screen of 800 x 600 pixels
int pixely[600] ;
int pixelx[800] ;

and would like to move to 300x 200
int pixely_new[200] ;
int pixelx_new[300] ;

Luckily it is not so complicated due to colors.

My pixels are either 0 or 1.
So it is black and white bitmap/array.


So this resizing might be occuring with less difficulties, but still, which method would you preferably recommend?
I had such a problem in visual basic before, but never got it really solved, and in C, it is much different ( and much better).

Thanks in advance

BenCollver 07-17-2013 11:59 PM

http://gnuwin32.sourceforge.net/packages/netpbm.htm

Xeratul 07-18-2013 09:43 AM

1 Attachment(s)
Quote:

Originally Posted by BenCollver (Post 4992316)

Let's take for instance this simple example...

http://s4.hubimg.com/u/562531_f260.jpg

Would be nice if we could get the array of pixels with simply stdio ;) kidding

Xeratul 07-18-2013 09:44 AM

Actually for windows, why not ?
libjpeg.dll

I dont like so much since it is not minimalist any longer

ta0kira 07-19-2013 10:15 AM

Take a look at some existing resampling algorithms.

Kevin Barry

John VV 07-19-2013 01:20 PM

for use in a c based program
convert the images to ppm

also have a look as G'Mic and CImg.h
http://gmic.sourceforge.net/

http://cimg.sourceforge.net/download.shtml
is what gmic is built on

Xeratul 07-20-2013 01:57 AM

oh yeah,
a fantastic thing is gimp !!

gimp can export to .h or .c and you can reload it.

Is there already a simple code that can display the .c one?


nothing to say... wikipedia is really clear and useful to understadn
http://en.wikipedia.org/wiki/Resampling_(bitmap)
they explain well

ta0kira 07-20-2013 10:56 AM

Quote:

Originally Posted by Xeratul (Post 4993610)
gimp can export to .h or .c and you can reload it.

That's pretty useful!
Quote:

Originally Posted by Xeratul (Post 4993610)
Is there already a simple code that can display the .c one?

This thread might be helpful.

Kevin Barry

Xeratul 07-23-2013 12:56 PM

Quote:

Originally Posted by ta0kira (Post 4993796)
That's pretty useful!This thread might be helpful.

Kevin Barry

thank you


well the question is whether this

pixmap *.c image file shall be converted either to X11 or ncurses?


All times are GMT -5. The time now is 04:03 AM.