|
-
Aug 16th, 2000, 02:52 PM
#1
Thread Starter
Junior Member
Hello
I'm writing a program which displays a Meteosat weather image. This is written pixel by pixel.
There are 2 problems
* When Im writing the image, I can't do anything else in my program. And I need to be able to use the stop button, so I can stop writing my image....
* I also need to be able to redraw my image when my program has been dropped down. When I use the autoredraw property, then the screen stays blank until the image has been received, and is then displayed. The target is to see form the pixel by pixel, and line by line..
Anyone who can help me???
This is the code I use
For lijn = 0 To 44
'teller om 440 pixels per lijn te schrijven
tel = 0
'440 pixels = 55 karakters
For karakter = 1 To 55
' ontvangen van data van de DSK
inbuff = RcvData
If inbuff = -1 Then
' Timemout
MsgBox "Timeout opgetreden", vbCritical, "TIMEOUT!!!"
Else
' Conversie van decimaal naar binair
Binary = Int(inbuff / 128) & Int(inbuff / 64) Mod 2 & _
Int(inbuff / 32) Mod 2 & Int(inbuff / 16) Mod 2 & _
Int(inbuff / 8) Mod 2 & Int(inbuff / 4) Mod 2 & _
Int(inbuff / 2) Mod 2 & inbuff Mod 2
' voor elke bit een pixel uitschrijven
For bitje = 1 To 8
Bit = Mid(Binary, bitje, 1)
If Bit = 0 Then
' zwart
kleur = RGB(0, 0, 0)
Else
' wit
kleur = RGB(255, 255, 255)
End If
tel = tel + 1
' pixel uitschrijven
frmDocument.Picture1.PSet (tel, lijn), kleur
Next bitje
End If
Next karakter
Next lijn
TNX
Viperke
-
Aug 16th, 2000, 03:25 PM
#2
Fanatic Member
Hallo
Aan de code zag ik dat je Nederlands bent dus kan ik net zo goed in het Nederlands gaan praten. Om de gebruiker de mogelijkheid te geven om ook nog op de stop knop te drukken moet je voor de laatste regel met next een regel invoegen met deze code:
Doevents
Nu zal het beter werken. Doei.
-
Aug 16th, 2000, 03:28 PM
#3
Insert DoEvents in your loops to stop your program from freezing.
-
Aug 16th, 2000, 03:31 PM
#4
Thread Starter
Junior Member
Dank u
TNX oetje, het werkt.
I hope that somebody else can help me with my redrawing problem.
I forgot to tel that I write my picture on a picturebox
TNX again
Viperke
Nogmaals dank oetje, BTW ben je van Nederland?
-
Aug 16th, 2000, 03:34 PM
#5
Fanatic Member
I also said that Megatron, but I said that in Dutch.
-
Aug 16th, 2000, 03:36 PM
#6
Fanatic Member
Viperke, ik kom uit Delfzijl. Je weet vast wel dat dat in het noorden van Nederland ligt. Waar kom jij vandaan?
-
Aug 16th, 2000, 03:41 PM
#7
Thread Starter
Junior Member
TNX Megatron!! It works :-))
Oetje ik woon in Lier tegen Antwerpen in België. En ik ben momneteel aan mijn thesis bezig die op 19/09/2000 af moet zijn, vandaar mijn vraag, en er zullen er nog meerdere volgen omdat ik nog niet veel ervaring heb in VB
Translation
Oetje I live in Lier next to Antwerp in Belguim.At this momnet I'm working on my thesis wich need to be ready before 19/09/2000. That was teh reason of my question, and I'm sure I'll ask more questions since I'm a beginner in VB.
Ik hoop dat de vertaling redelijk was, moet nog veel leren ...
-
Aug 16th, 2000, 03:44 PM
#8
Fanatic Member
Je kan me altijd een meeltje sturen. Mijn meel adres is [email protected]
-
Aug 19th, 2000, 04:45 AM
#9
Fanatic Member
Also try to use the PutPixel() API, much faster.
Use this function on a memory DC. Draw your picture first in memory, and then Blt it to your PictureBox.
You'll see that, in combination with DoEvents, the drawing process speed will increase a lot.
-
Aug 19th, 2000, 05:20 AM
#10
Thread Starter
Junior Member
Hello Mad Compie
TNX for the sollution, but for me is seems complicated. Since I'm a beginner, and I didn't had any experince with grafics. At this moment it work with oetjes sollution, but idd, it is rather slow....
But I'll try your sollution. But first I've got to read about it, because I don't know what is is t o draw on a memeory DC.
I let you know...
TNX anyway
-
Aug 19th, 2000, 06:08 AM
#11
Fanatic Member
*** Global declarations
Dim hDCmem As Long
Dim hBMTmp As Long
Dim HBMPrv As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
**** Form_Load()
hDCmem = CreateCompatibleDC(0)
hBMTmp = CreateCompatibleBitmap(Picture1.hdc, Picture1.ScaleWidth, Picture1.ScaleHeight)
HBMPrv = SelectObject (hDCmem, hBMTmp)
*** Form_Unload()
SelectObject hDCmem, HBMPrv
DeleteObject hBMTmp
DeleteDC hDCTmp
*** Code example
SrcColor = GetPixel(sourcepicture.hDC, x, y)
SetPixel hDCmem, x, y, SrcColor
...
BitBlt PictureBox.hDC, ..., hDCmem
-
Aug 19th, 2000, 08:58 AM
#12
Thread Starter
Junior Member
TNX
I'll give it a try
And I let you know
TNX!!!!!!!!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|