.NET CF Drawing Problems
- From: MoriCristian <CristianMori@xxxxxxxxxxxxx>
- Date: Sun, 20 Nov 2005 05:24:02 -0800
Hi!
Since DirectX are implemented only in mobile 5.0 and I must develop for
2003, I started to create a 3d engine on my own, but I get stuck immediatly
for performance problems.
I created dif function that draw a line using a Bresenham algorithm on a
Bitmap
private void DrawLine(Bitmap bmp, int x0, int y0, int x1,int y1)
{
int ddy,ddx,yi,xi,icx,icy,e;
ddy=y1-y0;
ddx=x1-x0;
if (ddx<0) icx=-1;
else icx=1;
ddx*=icx;
if (ddy<0) icy=-1;
else icy=1;
ddy*=icy;
e=0; xi=x0; yi=y0;
bool inv=false;
if (ddy>ddx) inv=true;
bool bquit=false;
if (!inv)
{
while(bquit==false)
{
bmp.SetPixel(xi,yi,Color.Black);
e=e+ddy;
if (2*e>ddx)
{
yi+=icy;
e=e-ddx;
}
xi+=icx;
if (xi==x1)
bquit=true;
}
}
else
{
while(bquit==false)
{
bmp.SetPixel(xi,yi,Color.Black);
e=e+ddx;
if (2*e>ddy)
{
xi+=icx;
e=e-ddy;
}
yi+=icy;
if (yi==y1)
bquit=true;
}
}
}
This algorithm was a start not only for line drawing, but also to implement
the goraud shading and texture mapping.
However, it is to slow, and the bottleneck is in the Bitmap.Setpixel!!!
Unfortunately there is no LockBits method as in the full .net framework, so
I cannot speed it up using this trick.
Is there any other way to do so?
I was thinking to keep a unmanaged Bitmap created by me (but I must first
discover how) do all the processing here and then blt it on the surface of
the pockepc.
Any advice is welcome
Thanks and regards
Cristian Mori
.
- Follow-Ups:
- RE: .NET CF Drawing Problems
- From: "Yuan Ren[MSFT]"
- RE: .NET CF Drawing Problems
- Prev by Date: Re: Fast way to read string one char at a time
- Next by Date: Re: 1.1 perf versus 2.0
- Previous by thread: RE: Fast way to read string one char at a time
- Next by thread: RE: .NET CF Drawing Problems
- Index(es):