Problem with DRAW or my "scanning" routine?
#6
@James D Jarvis

SOLVED!
the issue starts from the bug  that if you set a position on the screen and then you use a DRAW command to draws a line also of one pixel (S4r1) it draws the pixel of r command plus the pixel of the starting position!

buuut if you see at this your code you get the right output using a simple continue r command without bling moving of the graphic cursor.

Code: (Select All)
Rem 26 06 2023 SOLVED  TdB
'***************************************************************
'scanning a section of the screen converting and writing it with DRAW
'why doesn't it work?
'***************************************************************
Screen _NewImage(480, 400, 256)
$Console
_Console Off
Randomize Timer
Cls
_PrintMode _KeepBackground
_PrintString (0, 0), "AB"
'Line (1, 1)-(1, 14), 15
_Delay 0.5
msg$ = "<-- scanning this as a sample image"
_PrintString (40, 0), msg$
x = 0: y = 0
dd$ = ""
wid = 16
ht = 16
Draw "s4"
dd$ = Scan_draw$(x, y, ht, wid)
_Delay 1
Locate 4, 4
Line (40, 0)-(40 + Len(msg$) * 8, 15), 0, BF
msg$ = "ready (press any key)"
_PrintString (0, 100), msg$

Sleep
Line (0, 100)-(Len(msg$) * 8, 115), 0, BF
Locate 4, 4
Print "Draw Scanned image, Why isn't it drawing correctly?"
Print "Is the problem in the scanning routine or in how draw functions?"
putdraw 50, 0, dd$
drawto_console dd$
Input alldone$
End
'***************************************************************
' subroutines for making use of draw strings in 256 color mode.
' color 0 is treated as transpaernt
Sub putdraw (xx, yy, dd$)
    Draw "bm" + Str$(xx) + "," + Str$(yy) + dd$
End Sub
Sub drawto_console (dd$)
    'program must have console output activated earlier
    'prints the string in a clean console window so it may be copied and pasted on any system with console support
    sd& = _Dest
    _Console On
    _Dest _Console
    Cls
    Print dd$
    Print
    Print "Copy and Paste the above text for future use in DRAW commands"
    _Dest sd&
End Sub
Function Scan_draw$ (sx, sy, ht, wid)
    'scan a screen area starting at point sx,sy and saving it to the string DRW$ for use in later draw commands
    'simply scans each row and tracks color changes
    For y = 0 To ht - 1
        x = 0
        Do
            klr = Point(sx + x, sy + y)
            n = -1
            Do
                n = n + 1
                nklr = Point(x + n, y)

            Loop Until nklr <> klr Or x + n >= wid
            'If klr = 0 Then
            '    dd$ = dd$ + "br" + _Trim$(Str$(n))
            'Else
            dd$ = dd$ + "C" + _Trim$(Str$(klr)) + " " + "R" + _Trim$(Str$(n))
            ' End If
            x = x + n
        Loop Until x >= wid
        dd$ = dd$ + "bd1bl" + Str$(wid)
    Next y
    Scan_draw$ = dd$
End Function
in other words you have typed too code, REM out these lines of code 
Quote:'If klr = 0 Then
            '    dd$ = dd$ + "br" + _Trim$(Str$(n))
            'Else
       
            ' End If
and let work the  R command!
Quote:            dd$ = dd$ + "C" + _Trim$(Str$(klr)) + " " + "R" + _Trim$(Str$(n))
good continuation of developing you app
Reply


Messages In This Thread
RE: Problem with DRAW or my "scanning" routine? - by TempodiBasic - 06-25-2023, 06:12 PM



Users browsing this thread: 5 Guest(s)