LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-16-2013, 10:21 PM   #1
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,653

Rep: Reputation: 255Reputation: 255Reputation: 255
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
 
Old 07-16-2013, 11:20 PM   #2
BenCollver
Rogue Class
 
Registered: Sep 2006
Location: OR, USA
Distribution: Slackware64-15.0
Posts: 371
Blog Entries: 2

Rep: Reputation: 172Reputation: 172
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
 
Old 07-16-2013, 11:45 PM   #3
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,653

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by BenCollver View Post
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
 
Old 07-17-2013, 10:43 PM   #4
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,653

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
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
 
Old 07-17-2013, 11:59 PM   #5
BenCollver
Rogue Class
 
Registered: Sep 2006
Location: OR, USA
Distribution: Slackware64-15.0
Posts: 371
Blog Entries: 2

Rep: Reputation: 172Reputation: 172
http://gnuwin32.sourceforge.net/packages/netpbm.htm
 
Old 07-18-2013, 09:43 AM   #6
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,653

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by BenCollver View Post
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
Attached Thumbnails
Click image for larger version

Name:	562531_f260.jpg
Views:	18
Size:	7.8 KB
ID:	13008  
 
Old 07-18-2013, 09:44 AM   #7
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,653

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Actually for windows, why not ?
libjpeg.dll

I dont like so much since it is not minimalist any longer
 
Old 07-19-2013, 10:15 AM   #8
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Take a look at some existing resampling algorithms.

Kevin Barry
 
Old 07-19-2013, 01:20 PM   #9
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,622

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
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
 
Old 07-20-2013, 01:57 AM   #10
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,653

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
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
 
Old 07-20-2013, 10:56 AM   #11
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by Xeratul View Post
gimp can export to .h or .c and you can reload it.
That's pretty useful!
Quote:
Originally Posted by Xeratul View Post
Is there already a simple code that can display the .c one?
This thread might be helpful.

Kevin Barry
 
Old 07-23-2013, 12:56 PM   #12
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,653

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by ta0kira View Post
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?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Reading pixels of PNG image in C lghizoni Programming 4 10-22-2012 06:25 AM
grabbing data and displaying an image eoc92866 Programming 9 11-07-2010 07:02 AM
grabbing data and displaying an image eoc92866 Linux - Newbie 4 11-04-2010 11:15 PM
Help with displaying an image in PHP pandersson61 Programming 3 07-31-2008 09:40 PM
Strange mouse resolution ? 2 pixels by 2 pixels Creak Linux - General 8 04-18-2004 07:17 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration