|
Just a guess: I suppose you'll get this error when you call BeginScene twice without having called EndScene in between.
|
|
|
|
|
Yes, the problem is when I change the screen solution, something wrong happens and prevents the EndScene() call. So when the next BeginScene is called, it returns this error.
This is fixed. Anyway, thank you very much for your answer
|
|
|
|
|
Is it possible to use DirectX to render a 3d scene to a Bitmap instead of to a screen?
Using C# .Net 2 on XP.
It's not really suitable to put the render code into the paint event and then repeatedly call this.DrawToBitmap , so is there another way? Rendering to the Window is fine but so long as I can get the last rendered scene to a Bitmap (without having it re-render).
The reason I need the bitmap is because the image needs to be used again, such as in other windows (without having a bunch of near-identical and wasted devices). I suspect this may involve use of Surfaces?
Ninja (the Nerd)
Confused? You will be...
|
|
|
|
|
ive developed program using opengl with C for image processing operations and i run the code using visual studio.everything was working good for 256x256 images.but when i use images of more pixel size ...im having trouble with Fourier transformation.
if anyone know how to solve the error i will mail the code as it is lengthy...
|
|
|
|
|
kanika wrote: im having trouble with Fourier transformation.
Um, it would help if you said what kind of trouble.
kanika wrote: everything was working good for 256x256 images.but when i use images of more pixel size
Does the Fourier transform routine you're using have a requirement that the image size be a power of 2 and the larger images you're feeding it don't conform?
Believing in bullshit doesn't make it true.
|
|
|
|
|
yes,fft have to check the image size to power of 2.my code have 3 windows orginal image,source image and destination.when i give images less than 256x256 or more than 256z256 i cld get the output...but the image is disturbed in the related windows.
|
|
|
|
|
kanika wrote: when i give images less than 256x256 or more than 256z256 i cld get the output...but the image is disturbed in the related windows.
Is there a fundamental limit to image size for the routine which might be 256x256? It's kind of a suspicious since it represents 64k pixels which is the limit for an unsigned 16 bit integer.
Believing in bullshit doesn't make it true.
|
|
|
|
|
Hello. It may seem like a beginner question, but I'd like to know how to draw a line. Simple? I've been looking all over the net, and through these books I have, (also CodeProject) and nothing "works". Please help, thanks in advance.
- I love D-flat!
|
|
|
|
|
Hi,
for the Form, Panel, or whatever Control you want to draw on, use the OnPaint handler
(or add a new handler to the Paint event); it will give you a PaintEventArgs offering
a Graphics object, then use Graphics.DrawLine() and the like.
If you need examples, there are plenty around at CP. My Sokoban article also has some
line drawing.
[ADDED] just noticed some essential info got hidden in the subject line;
for XNA things are a bit more complicated, but they do provide some documentation,
so this may help[^].
[/ADDED]
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- 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 PRE tags to preserve formatting when showing multi-line code snippets.
modified on Sunday, January 13, 2008 5:03:32 PM
|
|
|
|
|
Oh, I know how to draw lines there. That's easy. BUT, in XNA, it's a whole new territory.
To your added reply, I've seen that, and tried, but wasn't sure what type the variables were when previously declared (they didn't show it there).
Example: points?
(My bad, I had pointList; it was points)
- I love D-flat!
modified on Sunday, January 13, 2008 5:10:42 PM
|
|
|
|
|
Not sure if this can be done simply, but hoping it can be. I want to draw shapes anywhere on the screen, regardless of my forms location. I want to be able to draw off the form. Can anyone provide guidance or even an example?
|
|
|
|
|
The ANZAC wrote: I want to draw shapes anywhere on the screen, regardless of my forms location. I want to be able to draw off the form.
You can't. You can only draw on your form.
|
|
|
|
|
|
i don't know, if this is what you are looking for, but i found that piece of vb.net-code on a cd:
<br />
Private Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Integer) As IntPtr<br />
Private Declare Function ReleaseDC Lib "user32" Alias "ReleaseDC" (ByVal hwnd As Integer, ByVal hdc As IntPtr) As Integer<br />
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
Dim blackPen As New Pen(Color.Black, 3)<br />
Dim dc As IntPtr<br />
Dim g As Graphics<br />
<br />
Dim rnd As New Random()<br />
Dim i As Integer<br />
dc = GetDC(0)<br />
g = Graphics.FromHdc(dc)<br />
For i = 0 To 1000<br />
g.DrawLine(blackPen, rnd.Next(600), rnd.Next(600), rnd.Next(600), rnd.Next(600))<br />
Next<br />
g.Dispose()<br />
ReleaseDC(0, dc)<br />
End Sub<br />
click on the button to draw a bunch of lines to the screen, independent of your form.
is this of any help?
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
hey,
can someone suggest good book or online material on 3d mesh manipulation that starts from basic concepts
thanks
|
|
|
|
|
The book 3D Computer Graphics, by Alan Watt, published by Addison Wesley, is really excellent.
|
|
|
|
|
I'm using GDI+, and want to edit the pixels of an 8 bit-per-pixel, grayscale bitmap which I read from a file. I can get the pixels using the Bitmap::LockBits and BitmapUnlockBits methods and a BitmapData object. However, there doesn't seem to be any support for 8 bit-per-pixel bitmaps that do not necessarily use a palette (i.e. grayscale).
I see that the pixel format can be set to PixelFormat8bppIndexed, and used along with a palette (the palette type can even be set to PaletteFlagsGrayScale). However, it is unnecessary to use a palette with these bitmaps, as the palette just contains all possible gray levels. It seems inefficient to have to associate a palette with these bitmaps and pass it back and forth each time the pixels are retrieved (the pixels are frequently and repeatedly passed back and forth for editing in my program).
Does anyone know:
1) Are there any other flags or methods for using BitmapData objects with 8 bit-per-pixel grayscale bitmaps but without a palette?
2) When the PaletteFlagsGrayScale flag is used, can I assume the palette entries are always the same (all possible gray levels)? Or can they be re-scaled? (I understand that these entries are DWORDs using alpha | red | green | blue, with the red, green and blue values equal to each other.)
Thanks!
|
|
|
|
|
Hi,
I have a windows CE device for which I am wrinting a C# .Net CF 2.0 application.
This device has an inclinometer chip connected to it, which reads the angles my device is at, and sends me the X and Y tilt values of the inclinometer.
Depending on those values, I want to display a picture. (.png). For now now I'm just using the X value (tiltX global variable)
The image is being updated every 150ms
So for a prototype I've being doing the following:
//TiltX is being passed in to RotateGauge as an Int.
private void RotateGauge(int side)
{
if (side > -5 & side < 5)
{
string number = Convert.ToString(side);
Stream sidePic = _assembly.GetManifestResourceStream("Rotate_Test.images.gauge.sideTilt" + (number) + ".png");
Bitmap bmp = new Bitmap(sidePic);
Graphics g = CreateGraphics();
g.DrawImage(bmp, 42,116); //draw image
bmp.Dispose();
sidePic.Close();
g.Dispose();
}
}
The above function RotateGauge() gets called from a timer. (interival 150ms)
The problem is its using up a lot of memory. I don't think I'm properly disposing of things.
Any suggestions how to : Efficiently rewrite the above code so when something gets created on a timer_tick it also gets disposed of properly
|
|
|
|
|
Hi,
I don't see anything wrong with your object disposal, so I expect the garbage collector
will clean up memory if need be.
However I think you are spending way too much CPU power to achieve your goals. This is
how I would do it:
- replace the PictureBox by a simple Panel (or an inherited Panel that sets its
ControlStyles to double-buffered for better graphics);
- do the drawing in the Panel's OnPaint method, based on a single class member (int side);
it gives you a Graphics for free (which you should not dispose!);
- when you want to change the gauge, change the variable (side) and call your Panel's
Invalidate method
If you only have a dozen PNG images, you may even consider keeping them alive in memory
all the time.
|
|
|
|
|
Hey Luc. Congratulations on your MVP status. It's well deserved.
|
|
|
|
|
Hi Pete, thanks. Congrats to you too.
I see several of us have reached the next station.
Mine came as a surprise, wasn't aware how many there would be, but even then...
|
|
|
|
|
Luc Pattyn wrote: Mine came as a surprise
Not to me. I had good money riding on you getting it.
It's nice not to have the yokel icon beside the names now. I like being a yellow diamond.
|
|
|
|
|
Pete O'Hanlon wrote: I had good money riding on you getting it.
Who is taking those bets? is that what is going on in the dark hours at the lounge?
Pete O'Hanlon wrote: It's nice not to have the yokel icon beside the names now. I like being a yellow diamond
Had to look that up, but I fully agree; it was/is not the nicest icon available.
BTW I think the golden diamond writer personality title I currently carry is the one I
like most (prolific fixture sounds really weird to me, I'll try to avoid it).
|
|
|
|
|
forgot to mention, I did notice how you skilfully reverted the topic to make it really fit
the graphics forum. A worthy diamond.
|
|
|
|
|
Hi Luc,
Thanks for your reply. I got overly excited when I saw 6 replies to my post as i've spent a lot of time trying to figure this out.
I attempted what you suggested, however the Compact Framework has me limited in what I can do.
The line of code I hoped to use for drawing in the panel is
g = panel1.CreateGraphics();
however, CreateGraphics is not availble to my panel in the CF. I'll keep looking, I'm very new to c# (programming in general) so there may be a solution for me somewhere.
Regards
Gemma
|
|
|
|