|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
need help on bitbltwebsite http://home.surewest.net/galen/index.html under Downloads. Basically I have a Panel that will get continuous updates and I don't want any flicker. In the test app it sets up a mem map and sets it to Black. When the Button is clicked it calls a routine that puts tick marks at top and bottom. The tick marks do not show up. Below is the Paint event. If I remark out the BitBlt and un-remark the e.Graphics line, the tick marks show up. But I know from experience that this method cause flicker when doing a lot of updates. I would appreciate any help I can get. Thanks GalenS Private Sub PictDraw_Paint(ByVal sender As Object, _ ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictDraw.Paint If bitmapflg Then 'e.Graphics.DrawImage(PictMap, e.ClipRectangle, e.ClipRectangle, GraphicsUnit.Pixel) BitBlt(PictDrawhDC, 0, 0, 715, 255, PicDrawhDC, 0, 0, SrcCopy) End If End Sub
Show quote
Hide quote
"Galen Somerville" <galen@community.nospam> schrieb You can not draw on a device context that has already been released.> I'm doing something wrong. I made up a test app and put the ZIP file > on my website > > http://home.surewest.net/galen/index.html under Downloads. > > Basically I have a Panel that will get continuous updates and I > don't want any flicker. In the test app it sets up a mem map and > sets it to Black. > > When the Button is clicked it calls a routine that puts tick marks > at top and bottom. The tick marks do not show up. > > Below is the Paint event. If I remark out the BitBlt and un-remark > the e.Graphics line, the tick marks show up. But I know from > experience that this method cause flicker when doing a lot of > updates. > > I would appreciate any help I can get. > > Thanks > GalenS > > Private Sub PictDraw_Paint(ByVal sender As Object, _ > ByVal e As System.Windows.Forms.PaintEventArgs) Handles > PictDraw.Paint If bitmapflg Then > 'e.Graphics.DrawImage(PictMap, e.ClipRectangle, > e.ClipRectangle, GraphicsUnit.Pixel) > BitBlt(PictDrawhDC, 0, 0, 715, 255, PicDrawhDC, 0, 0, > SrcCopy) End If > End Sub > > PictDrawhDC = GrpObj.GetHdc GrpObj.ReleaseHdc() After calling ReleasdHdc, PictDrawhDC is an invalid handle. Armin
Show quote
Hide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message I'll ckeck that out. I released it after looking at Amit's article on Using news:OtaVaAsTGHA.1708@TK2MSFTNGP14.phx.gbl... > "Galen Somerville" <galen@community.nospam> schrieb >> I'm doing something wrong. I made up a test app and put the ZIP file >> on my website >> >> http://home.surewest.net/galen/index.html under Downloads. >> >> Basically I have a Panel that will get continuous updates and I >> don't want any flicker. In the test app it sets up a mem map and >> sets it to Black. >> >> When the Button is clicked it calls a routine that puts tick marks >> at top and bottom. The tick marks do not show up. >> >> Below is the Paint event. If I remark out the BitBlt and un-remark >> the e.Graphics line, the tick marks show up. But I know from >> experience that this method cause flicker when doing a lot of >> updates. >> >> I would appreciate any help I can get. >> >> Thanks >> GalenS >> >> Private Sub PictDraw_Paint(ByVal sender As Object, _ >> ByVal e As System.Windows.Forms.PaintEventArgs) Handles >> PictDraw.Paint If bitmapflg Then >> 'e.Graphics.DrawImage(PictMap, e.ClipRectangle, >> e.ClipRectangle, GraphicsUnit.Pixel) >> BitBlt(PictDrawhDC, 0, 0, 715, 255, PicDrawhDC, 0, 0, >> SrcCopy) End If >> End Sub >> >> > > You can not draw on a device context that has already been released. > > PictDrawhDC = GrpObj.GetHdc > GrpObj.ReleaseHdc() > > After calling ReleasdHdc, PictDrawhDC is an invalid handle. > > > Armin Bitblt. GalenS
Show quote
Hide quote
"Galen Somerville" <galen@community.nospam> wrote in message I had to create hdc after setting PictMap to avoid error. Still same news:ubyRDPsTGHA.4308@TK2MSFTNGP10.phx.gbl... > > "Armin Zingler" <az.nospam@freenet.de> wrote in message > news:OtaVaAsTGHA.1708@TK2MSFTNGP14.phx.gbl... >> "Galen Somerville" <galen@community.nospam> schrieb >>> I'm doing something wrong. I made up a test app and put the ZIP file >>> on my website >>> >>> http://home.surewest.net/galen/index.html under Downloads. >>> >>> Basically I have a Panel that will get continuous updates and I >>> don't want any flicker. In the test app it sets up a mem map and >>> sets it to Black. >>> >>> When the Button is clicked it calls a routine that puts tick marks >>> at top and bottom. The tick marks do not show up. >>> >>> Below is the Paint event. If I remark out the BitBlt and un-remark >>> the e.Graphics line, the tick marks show up. But I know from >>> experience that this method cause flicker when doing a lot of >>> updates. >>> >>> I would appreciate any help I can get. >>> >>> Thanks >>> GalenS >>> >>> Private Sub PictDraw_Paint(ByVal sender As Object, _ >>> ByVal e As System.Windows.Forms.PaintEventArgs) Handles >>> PictDraw.Paint If bitmapflg Then >>> 'e.Graphics.DrawImage(PictMap, e.ClipRectangle, >>> e.ClipRectangle, GraphicsUnit.Pixel) >>> BitBlt(PictDrawhDC, 0, 0, 715, 255, PicDrawhDC, 0, 0, >>> SrcCopy) End If >>> End Sub >>> >>> >> >> You can not draw on a device context that has already been released. >> >> PictDrawhDC = GrpObj.GetHdc >> GrpObj.ReleaseHdc() >> >> After calling ReleasdHdc, PictDrawhDC is an invalid handle. >> >> >> Armin > > I'll ckeck that out. I released it after looking at Amit's article on > Using Bitblt. > > GalenS > Armin problem. Also tried not disposing GrpObj. Still same problem. GalenS Dim GrpObj As Graphics = PictDraw.CreateGraphics PictMap = New Bitmap(PictDraw.Width, PictDraw.Height, GrpObj) PictDrawhDC = GrpObj.GetHdc ' GrpObj.ReleaseHdc() GrpObj.Dispose()
Show quote
Hide quote
"Galen Somerville" <galen@community.nospam> schrieb I don't get what you're trying to accomplish.> > I'll ckeck that out. I released it after looking at Amit's article > > on Using Bitblt. > > > > GalenS > > > Armin > > I had to create hdc after setting PictMap to avoid error. Still same > problem. > Also tried not disposing GrpObj. Still same problem. > > GalenS > > Dim GrpObj As Graphics = PictDraw.CreateGraphics > PictMap = New Bitmap(PictDraw.Width, PictDraw.Height, GrpObj) > PictDrawhDC = GrpObj.GetHdc > ' GrpObj.ReleaseHdc() > GrpObj.Dispose() Maybe some general hints help: 'Drawing on a bitmap Dim g As Graphics Dim bmp As Bitmap bmp = New Bitmap(100, 100) g = Graphics.FromImage(bmp) g.Clear(Color.Black) g.DrawLine(Pens.White, 0, 0, 100, 100) g.Dispose() 'Drawing a bitmap using BitBlt in a Paint event Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As IntPtr, ByVal hObject As IntPtr) As IntPtr Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As IntPtr) As Boolean Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As IntPtr) As IntPtr Dim hdcSource, hdcDest As IntPtr Dim OldObject, hBmp As IntPtr hdcDest = e.Graphics.GetHdc hdcSource = CreateCompatibleDC(hdcDest) hBmp = bmp.GetHbitmap OldObject = SelectObject(hdcSource, hBmp) BitBlt(hdcDest, 0, 0, bmp.Width, bmp.Height, hdcSource, 0, 0, SrcCopy) SelectObject(hdcSource, OldObject) DeleteObject(hBmp) DeleteObject(hdcSource) e.Graphics.ReleaseHdc(hdcDest) Armin
Show quote
Hide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message I was a little vague on what I need. The app is getting a feed from a USB news:%23gsN5YtTGHA.5464@TK2MSFTNGP10.phx.gbl... > "Galen Somerville" <galen@community.nospam> schrieb >> > I'll ckeck that out. I released it after looking at Amit's article >> > on Using Bitblt. >> > >> > GalenS >> > >> Armin >> >> I had to create hdc after setting PictMap to avoid error. Still same >> problem. >> Also tried not disposing GrpObj. Still same problem. >> >> GalenS >> >> Dim GrpObj As Graphics = PictDraw.CreateGraphics >> PictMap = New Bitmap(PictDraw.Width, PictDraw.Height, GrpObj) >> PictDrawhDC = GrpObj.GetHdc >> ' GrpObj.ReleaseHdc() >> GrpObj.Dispose() > > > I don't get what you're trying to accomplish. > > Maybe some general hints help: > > 'Drawing on a bitmap > > Dim g As Graphics > Dim bmp As Bitmap > > bmp = New Bitmap(100, 100) > > g = Graphics.FromImage(bmp) > g.Clear(Color.Black) > g.DrawLine(Pens.White, 0, 0, 100, 100) > g.Dispose() > > > > > 'Drawing a bitmap using BitBlt in a Paint event > > Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As IntPtr, > ByVal hObject As IntPtr) As IntPtr > Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As > IntPtr) As Boolean > Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As > IntPtr) As IntPtr > > Dim hdcSource, hdcDest As IntPtr > Dim OldObject, hBmp As IntPtr > > hdcDest = e.Graphics.GetHdc > hdcSource = CreateCompatibleDC(hdcDest) > hBmp = bmp.GetHbitmap > OldObject = SelectObject(hdcSource, hBmp) > > BitBlt(hdcDest, 0, 0, bmp.Width, bmp.Height, hdcSource, 0, 0, > SrcCopy) > > SelectObject(hdcSource, OldObject) > DeleteObject(hBmp) > DeleteObject(hdcSource) > e.Graphics.ReleaseHdc(hdcDest) > > > > > Armin > device with four samples worth of data about every 12 milliseconds. There are various subs in various modules that will be drawing to the Panel (or PictureBox if better). This is like an oscilloscope trace of Heart sounds. It works fine when I use the e.Graphics,etc in the Paint event. But the display flickers badly. It was suggested I use a double buffer technique. But all of the help samples I could find just show how to do it for one operation. Of course I need to do it continually. Also they all show doing the work in a Paint event. I would have to have a monster set of Select Cases or If Elses to do it all in the Paint Event. Not shown in the TestBitblt demo is the fact that the Panel (or PictureBox) could be on one of two forms. Therefore I have to pass the Form info to the various subs. Finally, a little sour grapes, this was easy to do in VB6. GalenS "Galen Somerville" <galen@community.nospam> schrieb Why for one operation only?> I was a little vague on what I need. The app is getting a feed from > a USB device with four samples worth of data about every 12 > milliseconds. There are various subs in various modules that will be > drawing to the Panel (or PictureBox if better). > > This is like an oscilloscope trace of Heart sounds. It works fine > when I use the e.Graphics,etc in the Paint event. But the display > flickers badly. It was suggested I use a double buffer technique. > But all of the help samples I could find just show how to do it for > one operation. Of course I need to do it continually. > Also they all show doing the work in a Paint event. I would have to Why do you need many cases?> have a monster set of Select Cases or If Elses to do it all in the > Paint Event. > Not shown in the TestBitblt demo is the fact that the Panel (or Why do you have to pass the Form?> PictureBox) could be on one of two forms. Therefore I have to pass > the Form info to the various subs. > Finally, a little sour grapes, this was easy to do in VB6. I would create a control that encapsulates the drawing. Set styles ControlStyles.AllPaintingInWmPaint, ControlStyles.UserPaint, ControlStyles.ResizeRedraw and ControlStyles.DoubleBuffer. Pass the data to properties of the control. In OnPaint, paint depending on the data passed. You can put the Control on as many forms as you like. Armin inline
Show quoteHide quote "Armin Zingler" <az.nospam@freenet.de> wrote in message What I meant was that the help samples would show how to transfer a color news:eqBLE41TGHA.1688@TK2MSFTNGP11.phx.gbl... > "Galen Somerville" <galen@community.nospam> schrieb >> I was a little vague on what I need. The app is getting a feed from >> a USB device with four samples worth of data about every 12 >> milliseconds. There are various subs in various modules that will be >> drawing to the Panel (or PictureBox if better). >> >> This is like an oscilloscope trace of Heart sounds. It works fine >> when I use the e.Graphics,etc in the Paint event. But the display >> flickers badly. It was suggested I use a double buffer technique. >> But all of the help samples I could find just show how to do it for >> one operation. Of course I need to do it continually. > > Why for one operation only? block and then dispose of everything. > Different subs draw in different ways. If all in one Paint Event it would >> Also they all show doing the work in a Paint event. I would have to >> have a monster set of Select Cases or If Elses to do it all in the >> Paint Event. > > Why do you need many cases? have to know which way was currently required. > If the effective bitmap were Global, I guess I wouldn't>> Not shown in the TestBitblt demo is the fact that the Panel (or >> PictureBox) could be on one of two forms. Therefore I have to pass >> the Form info to the various subs. > > Why do you have to pass the Form? > Good point. I have user controls for other purposes. I never thought of >> Finally, a little sour grapes, this was easy to do in VB6. > > > I would create a control that encapsulates the drawing. Set styles > ControlStyles.AllPaintingInWmPaint, ControlStyles.UserPaint, > ControlStyles.ResizeRedraw and ControlStyles.DoubleBuffer. Pass the data > to properties of the control. In OnPaint, paint depending on the data > passed. You can put the Control on as many forms as you like. > > > Armin doing it for Graphics displays. I will get right on it. GalenS
Installation Error: Application validation did not succeed. Unable to continue
Serializing custom properties on a BindingList. what is Xtreme Sample Database Data Source with ReportViewer How display Result from sqlCommand select in the Datagridview Small bit of code from VB6 to VB.net - desperate need of help Multithreading and ActiveX BackgroundWorker and 'freezing' application set back ground image to stretch how to capture print message |
|||||||||||||||||||||||