|
Hi,
I don't see where the problem could be (unless you hope to solve this with a PictureBox ). Here are some thoughts, they may not be optimal, just intended to show a possible way:
1.
if you have an image of the world (say from longitude 0 to long 360), then you need to paint it in two steps, first from your starting longitude x0 upto 360, then from 0 to the right border (x0 again). So calling some overload of Graphics.DrawImage twice should do it.
An altenative is to construct a double-sized image once (that is from 0 to 360 and again from 0 to 360)
and then paint the right part of it.
2.
if you are drawing the world yourself, you can draw it in the regular way, you only need to adjust the x coordinate and again tranform the longitudes [0,360) to [x0...360, 0...x0).
This by itself could be handled by modifying all x coordinates; or more easily by having your paint code execute twice, once with a translation that takes care of the left part so [0, x0) gets clipped of at the left, and once with a translation that takes care of the right part so [x0, 360) gets clipped of at the right.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Thanks for your help.
Jim
this thing looks like it was written by an epileptic ferret
Dave Kreskowiak
|
|
|
|
|
You're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Im having trouble with the game im making (nothing fancy just my first 2D game)
and I almost got it complete, but i cant figure a way to get it to pause durring the game.
Im kinda new at DirectX so its probly simple, but ive looked everywhere,
someone recomended system pause but ive read that it should be avoided.
Anyone got any ideas? Or at least a hint in the right direction?
|
|
|
|
|
I assume you have a game loop in your project - if you do, then all you need to do is put a simple check into the loop to determine whether your game has paused or not. If you are in a pause, then the loop does no processing.
|
|
|
|
|
I am using graphics to create a speed meter.
To do this I would like to draw a line from the center of the circle to the side of the circle. You would normaly use sinus etc. for this, but my circle isn't really round, it's more oval like (the height is bigger than the width).
How is it possible to draw this line?
|
|
|
|
|
Hi,
a circle with radius r at the origin is represented by x*x + y*y = r*r
an ellips with big radius r at the origin is represented by x*x + a*a*y*y = r*r
where a (a factor larger than 1) is the ratio between the large radius (along the x-axis) and the small radius (along the y-axis).
So basically an ellips is a circle where you reduce y to y/a, and for each point (x,y) that would sit on the circle, the point (x, y/a) would sit at the corresponding location on the ellips.
To visualize: paint a circle on a sheet of paper, now tilt the sheet around a horizontal line: the circle becomes an ellips and all vertical dimensions shrink by the same factor.
Depending on what you want exactly, this might be all you need. When angles are involved, it gets a little bit more complex.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Thank you for explaining this. Seems not to hard.
But my question is indeed about angles.
If you would like to take a gast look to this picture so you understand what I'm making:
http://technology.amis.nl/blog/wp-content/images/postReadSpeedSpeedo.jpg[^]
The thing I want to make is an arrow like that based on an angle. The shape of the arrow is not a big deal, it's about the angle and how to know the length of the arrow.
|
|
|
|
|
Well, that image shows a circle, if all you want to do is compress or stretch it in one dimension, then just do that by multiplying one coordinate by a constant factor. Give it a try in an app such as Photoshop by changing one component of the image size (uncheck "keep aspect ratio" or whatever they called it).
The one situation where you would need angle stuff is where you would want an arrow moving at a constant angular speed in the ellips (which would not then be a constant angular speed in the corresponding circle).
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Yes, you're totaly true that I can use a photoshop-like program.
But I really want to calculate it on my own.
The picture is created by code, everything has to be configurable, for instance: the hight, the width, the amount of arrows and where the arrows point to.
The problem is that the width is not always equal to the height. So that's the only problem I have. I know it is possible because it's allready solved by microsoft (Graphics.drawPie).
I hope that you can tell me how to calculate this eclipse like with the only variables you have: the angle, the width, the height.
|
|
|
|
|
Still having a hang-over from mardi gras?
I explained how ellipses work. I gave you the math.
I suggested you look at your picture, when Photoshop stretches it, so you don't have to create or modify any code to see and maybe understand how a scale transform turns a circle into an ellipse.
By now you should realize all it takes is adding a scale factor to your Graphics code, either explicitly or by providing a ScaleTransform or Matrix.
For me this topic is closed.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Lol yeah it's the beer :P.
I didn't realize it was just about adding the scale factor , now I do.
And I thought you suggested to stretch the picture in photoshop, just for visualisation.
Thank you for your help
|
|
|
|
|
|
IF:
Xo, Yo - the center of the ellipse
Rx, Ry - the two radius'
alpha - is the angle in radians!!!
Calculate:
X = Xo + Rx*cos(alpha);
Y = Yo + Ry*sin(alpha);
Draw:
a line from (Xo,Yo) to (X,Y)
*In case you have a circle, then Rx=Ry = R of circle
|
|
|
|
|
Btw, if you want to implement as it was on the picture, I would highly recommend using a circle, because otherwise the length of the hands will vary, which is not realistic.
|
|
|
|
|
Hi all,
This is with reference to an old message posted by me which you can find here
http://www.codeproject.com/script/Forums/View.aspx?fid=387159&msg=2452196[^]
For the past one year this piece of code which Mr.Mark gave me; satisfied my requirements excellently. Now I have come up with a problem of displaying colour video. I will need help once again in modifying the code to colour mode. The main problem is how I should arrange the pixels and where to write it. What are the BITMAPINFO parameters that I have to change. Hope to get a reply at the earliest.
|
|
|
|
|
How many bits per pixel (what's the pixel format)?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
8 bit per pixel in RGB format.I have three arrays of unsigned char for each R,G and B values.
|
|
|
|
|
So do you mean 24 bits per pixel? There's no 8bpp RGB format for Windows bitmaps...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
To create the DIBSection, you can drop the palette and change the bmiHeader.biBitCount:
BITMAPINFO *bm = (BITMAPINFO *)new BYTE[sizeof(BITMAPINFO)];
bm->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bm->bmiHeader.biWidth = 176;
bm->bmiHeader.biHeight = 144;
bm->bmiHeader.biPlanes = 1;
bm->bmiHeader.biBitCount = 24;
bm->bmiHeader.biCompression = BI_RGB;
bm->bmiHeader.biSizeImage = 0;
bm->bmiHeader.biXPelsPerMeter = 0;
bm->bmiHeader.biYPelsPerMeter = 0;
bm->bmiHeader.biClrUsed = 0;
bm->bmiHeader.biClrImportant = 0;
BYTE *pBitmapBits;
HBITMAP hBitmap = ::CreateDIBSection(NULL, bm, DIB_RGB_COLORS, (void**)&pBitmapBits, NULL, 0);
if (hBitmap)
{
::DeleteObject(hBitmap);
}
delete[] (BYTE *)bm;
jossion wrote: I have 8 bits of R,8 bits of G and 8 bits of B seperately in seperate arrays
The pixel data (pointed to by pBitmapBits) will now be a RGBTRIPLE struct for each pixel:
typedef struct tagRGBTRIPLE {
BYTE rgbtBlue;
BYTE rgbtGreen;
BYTE rgbtRed;
} RGBTRIPLE;
You'll need to take the individual RGB component bytes from the arrays and
pack them in the RGBTRIPLE format - BGRBGRBGR...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I would suggest:
bm->bmiHeader.biHeight = -144;
instead of
bm->bmiHeader.biHeight = 144;
When height is positive, the bitmap is bottom-up oriented.
In 99% our bitmap sources are up-bottom oriented.
|
|
|
|
|
That's fine....as long as the OP remembers to adjust his/her
direct pixel access calculations accordingly
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i used the gluTessCallback() function to draw polygon, i can draw it in one computer, but can not draw in another computer, the two computer has diffrent graphic card. what is the matter, and how can resolve the question?
thanks
|
|
|
|
|
Hello ~
Can i ask Some question abo ut zedgraph here??
anyway this is my first question in code project ^^
and i can't english well plz comprehension my writing
let's start question
now My company Project Using Zedgraph.dll ver:5.1.4(maybe)
in the Project using zedgraph namespace
and i complete Drawing the Graph
only user X axis, Y axis
data is X[30] , T[30] <-- this data is ReadlTime data and Changing 3sec
Graph is Drawing but 3sec draw the Line, and 6sec draw the Line.. so on
Time is Gone...Line is so Many Many and i don't want it
for example)
0sec
3sec Draw the Line~~~~ Having data X[30] , T[30](data always chaging every
3sec)
and i want clear the line <-- this is i want
6sec Draw the Line~~~~ Having data X[30] , T[30](data always chaging every 3sec)
so on.....
how do i clear the Line ??
check this out my source
private void CreateGraph(double[] X, double[] T) //제드그래프 생성 (X,Y값을 가져옴)
{
GraphPane myPane = zgc.GraphPane;
// Set the titles and axis labels/;/l
myPane.Title.Text = "My Test Date Graph";
myPane.XAxis.Title.Text = "X";
myPane.YAxis.Title.Text = "Y";
// Make up some data points from the Sine function
PointPairList list = new PointPairList();
for (int i = 0; i < X.Length; i++)
{
list.Add(X[i], T[i]);
}
/*
for (double x = 0; x < 36; x++)
{
double y = Math.Sin(x * Math.PI / 15.0);
list.Add(x, y);
}
*/
// Generate a blue curve with circle symbols, and "My Curve 2" in the legend
LineItem myCurve = myPane.AddCurve("내부온도", list, Color.Blue,
SymbolType.Circle);
myCurve.Line.Fill = new Fill(Color.White, Color.Red, 45F);
// Make the symbols opaque by filling them with white
myCurve.Symbol.Fill = new Fill(Color.White);
// Make the symbols opaque by filling them with white
myCurve.Symbol.Fill = new Fill(Color.White);
// Fill the axis background with a color gradient
myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F);
// Fill the pane background with a color gradient
myPane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45F);
// Calculate the Axis Scale Ranges
zgc.AxisChange();
Refresh();
|
|
|
|
|