LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-12-2015, 02:47 PM   #1
Krupski
Member
 
Registered: Jan 2015
Location: The worst state in USA (can you guess?)
Distribution: Debian 11 (x86_64)
Posts: 44

Rep: Reputation: 0
Graphic (bitmap) window generation and use


Hi all,

Years ago I wrote a small program in GWBASIC that read in a binary file, created a graphics screen, scaled the X axis according to the file size and "plotted" the contents of the file graphically.

It didn't measure anything - I used it more for quick checking that I wrote some code properly. For example, if I generated a file with sin(x) values, I would open it with my little graph program and visually see "yup, it's a sine wave".

I would like to do this in Linux (I use KUbuntu 14.04 by the way).

All I need is to know how to create a graphics screen (window?) of a specified size, then turn on or off (with colors maybe) pixels in the bitmap to generate the image.

I know how to do everything else (open the file, read it, scale data, etc) all I need to know is a SIMPLE way to create a screen and control the pixels based on their X and Y location.

If anyone can point me in the right direction or provide some help, I will really appreciate it. Thanks!

P.S. I want to do this in C or C++ - console mode. That is, at a command prompt I want to type "graph data.file" and have the screen pop open and display my data.

-- Roger

Last edited by Krupski; 01-12-2015 at 02:51 PM. Reason: fixed typo
 
Old 01-12-2015, 05:58 PM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
If this really is only a tool to see the contents of a file in a graph, use gnuplot. You can use it interactively from the command line. Plotting a file would be something like entering the command
Code:
plot "test.dat" using 1:2 with lines
This will pop up a window and display the graph from columns 1 and 2 of the data file. There are a zillion options you don't want to learn or to use, but the most relevant might be adding a grid and setting the X and Y scales.

jlinkels

Last edited by jlinkels; 01-12-2015 at 05:59 PM.
 
Old 01-13-2015, 07:37 AM   #3
Krupski
Member
 
Registered: Jan 2015
Location: The worst state in USA (can you guess?)
Distribution: Debian 11 (x86_64)
Posts: 44

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jlinkels View Post
If this really is only a tool to see the contents of a file in a graph, use gnuplot.
Thank you for the reply... and I'm sure this would work fine... but it's not what I asked.

I'm sure (well at least I'm hoping) that it's possible to just do something like this (pseudo-code):

Code:
// create a white screen, watch pixels walk across
ptr = window_create (640, 480, 0xffffff); // 640x480 screen, white background
for (int x = 0; x < 640; x++) {
    for (int y = 0; y < 480, y++) {
        ptr.setpoint (x, y, 0x000000); // set pixel to black
        usleep (1e3 * 100); // sleep 100 msec
        ptr.setpoint (x, y, 0xffffff); // reset pixel to white
    }
}
This is more or less what I'm after. Nothing complicated.

The "point" (no pun intended) is that I can selectively control every pixel in the window, because I also want to preview font bitmaps (the kind used in VFD/LCD display modules).

For what I'm doing, I need to create a bitmap font, then when it's "right" (as determined by visualizing it in a graphic window), I have to scale it and rotate it 90 degrees CW to be used in the display (a 128 x 64 pixel KS-108 style VFD or LCD).

Another thing it would be used for is having an LCD touch screen on an Arduino microcontroller and using it to draw an arbitrary waveform shape, then uploading it to the PC (which will generate an output signal based on the shape of the arbitrary curve I drew) as well as displaying it on the PC.

The "arbitrary waveform generator" program will be a console mode program, but with a little monitor "window" to show what's going on.

Sorry for the long winded explanation, but I wanted you to see WHY I needed what I asked for, as opposed to just using "some program".

I would also, of course, use the same technique for graphing random files (such as short audio [WAV} files consisting of several sine waves summed together), but primarily what I want is a window that I can control at the pixel level.

There are a lot of graphing, plotting and curve fitting programs "out there", but none of them do what I need as described above.

Thanks again for the reply!

-- Roger
 
  


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
No graphic window kabacis Linux - Newbie 2 06-11-2008 01:04 PM
how to draw a bitmap in the window using xlib mirsoft Programming 1 02-10-2008 09:38 AM
how to draw a bitmap in the window using xlib mirsoft Programming 4 01-23-2008 06:56 PM
how to save a graphic window abd_bela Programming 3 08-02-2007 03:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:19 PM.

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