Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with DRAW or my "scanning" routine?
#1
Is the problem with my scanning/conversion routine or how DRAW actually draws?
(The draw statements it produces could be optimized to be briefer, I just haven't done that here. I want to get the scanning and rendered correctly first).

Code: (Select All)
'***************************************************************
'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
Reply


Messages In This Thread
Problem with DRAW or my "scanning" routine? - by James D Jarvis - 06-23-2023, 04:34 PM



Users browsing this thread: 3 Guest(s)