Insider1984
Technical User
Hi there. I've been using GDI to display a bitmap that I update line by line for a certain application as the lines come in. The problem is that GDI is slow when the image gets big and of course GDI is becoming emulation in Vista.
I'm looking at Managed DirectX to do this. I have some knowledge and examples of setting up a primary surface which has a secondary surface on it which is assigned to a bitmap.
Now, I'm trying to do exactly what I do in GDI where I'll lock the area of the bitmap I want to modify, I write to the memory location I want to change then release the bitmap and expect to see an update.
I do not see the update and I have also tried a number of "Redraw" and other commands into the Direct X to display it.
Here are some snips of code for testing only, excuse the messy, bad programming styles.
update function
creation of surfaces:
=====================
Insider
4 year 'on the fly' programmer
C, C++, C#, MFC, Basic, Java ASP.NET
I'm looking at Managed DirectX to do this. I have some knowledge and examples of setting up a primary surface which has a secondary surface on it which is assigned to a bitmap.
Now, I'm trying to do exactly what I do in GDI where I'll lock the area of the bitmap I want to modify, I write to the memory location I want to change then release the bitmap and expect to see an update.
I do not see the update and I have also tried a number of "Redraw" and other commands into the Direct X to display it.
Here are some snips of code for testing only, excuse the messy, bad programming styles.
update function
Code:
BitmapData display = graphics.z.LockBits(new Rectangle(0, a,400, 1), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
BitmapData imageIn = b.LockBits(new Rectangle(0, a, 400, 1), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
unsafe
{
byte* imgPtr = (byte*)(display.Scan0);
byte* imgPtr1 = (byte*)(imageIn.Scan0);
//for (int i = 0; i < display.Height; i++)
//{
for (int j = 0; j < display.Width; j++)
{
*imgPtr = *imgPtr1;
imgPtr += 1;
imgPtr1 += 1;
}
imgPtr += display.Stride - display.Width * 3;
imgPtr1 += display.Stride - display.Width * 3;
//}
}
b.UnlockBits(display);
graphics.z.UnlockBits(imageIn);
a++;
creation of surfaces:
Code:
SurfaceDescription desc = new SurfaceDescription();
SurfaceCaps caps = new SurfaceCaps();
localClipper = new Clipper(localDevice);
localClipper.Window = owner;
desc.SurfaceCaps.PrimarySurface = true;
surfacePrimary = new Surface(desc, localDevice);
//surfacePrimary = new Surface(@"C:\c.bmp", desc, localDevice);
surfacePrimary.Clipper = localClipper;
desc.Clear();
desc.SurfaceCaps.OffScreenPlain = true;
desc.Width = surfacePrimary.SurfaceDescription.Width;
desc.Height = surfacePrimary.SurfaceDescription.Height;
surfaceSecondary = new Surface(z, desc, localDevice);
surfaceSecondary.FillStyle = 0;
desc.Width = 100;
desc.Height = 50;
surfaceText = new Surface(desc, localDevice);
surfaceText.ForeColor = Color.Red;
=====================
Insider
4 year 'on the fly' programmer
C, C++, C#, MFC, Basic, Java ASP.NET