Results 1 to 12 of 12

Thread: Redrawing

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Location
    Antwerp
    Posts
    20

    Exclamation

    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
    Viperke

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    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.

  3. #3
    Guest
    Insert DoEvents in your loops to stop your program from freezing.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Location
    Antwerp
    Posts
    20

    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?

    Viperke

  5. #5
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    I also said that Megatron, but I said that in Dutch.

  6. #6
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Viperke, ik kom uit Delfzijl. Je weet vast wel dat dat in het noorden van Nederland ligt. Waar kom jij vandaan?

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Location
    Antwerp
    Posts
    20
    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 ...
    Viperke

  8. #8
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Je kan me altijd een meeltje sturen. Mijn meel adres is [email protected]

  9. #9
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553

    Smile

    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.

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Location
    Antwerp
    Posts
    20
    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
    Viperke

  11. #11
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553

    Lightbulb

    *** 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


  12. #12

    Thread Starter
    Junior Member
    Join Date
    Apr 2000
    Location
    Antwerp
    Posts
    20

    Thumbs up

    TNX

    I'll give it a try

    And I let you know

    TNX!!!!!!!!!!
    Viperke

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width