Hi,
I have created a GDI application which has to display some signals on the screen (sin wave, square wave, etc). I have a display with a set size(for example 640x480). The data that I plot is taken from a 1d array of doubles. After some calculations I create 2d array from it and I plot this one. And so far everything is working fine.
The problems is that the user should be able to specify the length of the input data. For example the user specifies that the input array is 1000 elements, and the display is 640 points wide.
How can I resize the data, so that it fits exactly in the display? What kind of tricks/algorithms can I use?
I came up with a solution but it is not a nice one. What I currently do is for example:
- the display is 640 pixels
- the data is 6400 values
So: data/pixels = 6400/640 = 10, which means that every tenth value occupies a new pixel on x-axes of the display. These ten values that are inbetween occupy pixels on the y-axes of the display.
Now if the data is 1000 values, I will plot it, but the last couple of pixels on the display will remain empty.
I am looking for suggestions?
Thank you in advance,
Greetings, Nedelin.
Plot data
Started by nedsana, Aug 12 2010 03:47 AM
4 replies to this topic
#1
Posted 12 August 2010 - 03:47 AM
|
|
|
#2
Posted 12 August 2010 - 05:29 AM
Try to use Vectors instead of arrays and resize the pixels with respect to user input. Because if you store your values in an array, there is no way to resize it other than creating a new one.
Hope it helps!
Hope it helps!
#3
Posted 12 August 2010 - 06:31 AM
Hi,
I don't want to change the number of the pixels of the display.
I write this program in simple C. There are no vectors and stuff. Besides I am not really used to vectors, and honestly prefer to avoid them.
I am looking for some standarts for creating plots. Some general guidelines.
I don't want to change the number of the pixels of the display.
I write this program in simple C. There are no vectors and stuff. Besides I am not really used to vectors, and honestly prefer to avoid them.
I am looking for some standarts for creating plots. Some general guidelines.
#4
Posted 12 August 2010 - 06:53 AM
Sorry, thought you were using Java, can u check this link,
256-Color VGA Programming in C
There are nice examples that can give u an idea of what to do
Cheers!
256-Color VGA Programming in C
There are nice examples that can give u an idea of what to do
Cheers!
#5
Posted 12 August 2010 - 07:03 AM
Thank you,
I will take a look at you link.
I will take a look at you link.


Sign In
Create Account

Back to top









