Author Topic: Simple unoptimised picture zoomer.  (Read 3882 times)

0 Members and 1 Guest are viewing this topic.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Simple unoptimised picture zoomer.
« on: January 17, 2008 »
Source only;
(it generates it's own pic).

Code: [Select]
'
' BY SHOCKWAVE
' ZOOMS WHATEVER IS IN PICTUREBUFFER AND DISPLAYS ON BUFFER
   
    OPTION STATIC
    OPTION EXPLICIT
   
    #INCLUDE "TINYPTC_EXT.BI"
    #INCLUDE "WINDOWS.BI"

'-------------------------------------------------------------------------------
' SCREEN STUFF ;
'-------------------------------------------------------------------------------

    CONST   XRES    =    640
    CONST   YRES    =    480


    DIM SHARED AS UINTEGER BUFFER ( XRES * YRES )


'-------------------------------------------------------------------------------
' COPY THIS;
'-------------------------------------------------------------------------------

    DIM SHARED AS UINTEGER PICBUFFER ( XRES * YRES )
   
    DECLARE SUB FILL_PICBUFFER()
    DECLARE SUB DRAWPICBUFFER(BYVAL PX1 AS DOUBLE,PY1 AS DOUBLE,BYVAL PX2 AS DOUBLE,PY2 AS DOUBLE,BYVAL PX3 AS DOUBLE,PY3 AS DOUBLE,BYVAL PX4 AS DOUBLE,PY4 AS DOUBLE)
    FILL_PICBUFFER()
 
    PTC_ALLOWCLOSE(0)
    PTC_SETDIALOG(1,"",0,0)               
    IF (PTC_OPEN("C-I-R-C-U-L-A-R",XRES,YRES)=0) THEN
    END-1
    END IF     
   
    DIM ZOOM AS INTEGER
    DIM AS DOUBLE XP1,XP2,XP3,XP4,YP1,YP2,.YP3,YP4
    XP1=320
    XP2=320
    YP1=240
    YP2=240
    DIM SS AS DOUBLE
    SS=TIMER
WHILE((GETASYNCKEYSTATE(VK_ESCAPE)<> -32767))
IF TIMER-SS>3 AND TIMER-SS<15 THEN
IF XP1>0 THEN XP1=XP1-1.34
IF XP2<XRES THEN XP2=XP2+1.34
IF YP1>0 THEN YP1=YP1-1
IF YP2<YRES THEN YP2=YP2+1
END IF


IF TIMER-SS>15 THEN
IF XP1<320 THEN XP1=XP1+1.34
IF XP2>320 THEN XP2=XP2-1.34
IF YP1<240 THEN YP1=YP1+1
IF YP2>240 THEN YP2=YP2-1
END IF

    DRAWPICBUFFER(XP1,YP1,XP2,YP1,XP1,YP2,XP2,YP2)
   
    PTC_UPDATE@BUFFER(0)
    ERASE BUFFER
WEND


'-------------------------------------------------------------------------------
' GENERATE RANDOM PICTURE!
'-------------------------------------------------------------------------------

SUB FILL_PICBUFFER()
    DIM AS INTEGER X,Y,C
   
    FOR Y=0 TO YRES-1
    FOR X=0 TO XRES
        C= X XOR Y
        PICBUFFER(X+(Y*XRES))=RGB(C,C,C)
    NEXT
    NEXT

END SUB


SUB DRAWPICBUFFER(BYVAL PX1 AS DOUBLE,PY1 AS DOUBLE,BYVAL PX2 AS DOUBLE,PY2 AS DOUBLE,BYVAL PX3 AS DOUBLE,PY3 AS DOUBLE,BYVAL PX4 AS DOUBLE,PY4 AS DOUBLE)

        DIM AS DOUBLE INTERX,INTERY, AX,AY
        DIM AS INTEGER XL,YL

        AX=0
        AY=0
       
        INTERX=XRES/(PX2-PX1)
        INTERY=YRES/(PY3-PY1)

FOR YL=PY1 TO PY4
   
    IF  YL>5 AND YL<YRES-5 THEN
    FOR XL=PX1 TO PX2
       
        IF XL>1 AND XL<XRES-1 THEN
        BUFFER(XL+(YL*XRES))=PICBUFFER(INT(AX)+(INT(AY)*XRES))
        END IF
        AX=AX+INTERX
       
    NEXT
    END IF

    AY=AY+INTERY
    AX=0
NEXT

END SUB
Shockwave ^ Codigos
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Simple unoptimised picture zoomer.
« Reply #1 on: January 17, 2008 »
I would love to see it ... any chance of supplying an exe ?
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Simple unoptimised picture zoomer.
« Reply #2 on: January 17, 2008 »
Lol, I knew I'd have to post an exe :) Why didn't I do it in the first place?
Ok, leave it for a few seconds after you run it for the effect to happen.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Simple unoptimised picture zoomer.
« Reply #3 on: January 17, 2008 »
Thanks shocky. That runs very smooth here. Looks great.
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Simple unoptimised picture zoomer.
« Reply #4 on: January 17, 2008 »
It can be sped up easily with pointers :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Simple unoptimised picture zoomer.
« Reply #5 on: January 17, 2008 »
Looks good and the source is very neat and compact. This is a great example to learn from

Challenge Trophies Won:

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: Simple unoptimised picture zoomer.
« Reply #6 on: January 17, 2008 »
Nice code. As already said by rain_storm, great example to learn from - thanks again!

Drew
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Simple unoptimised picture zoomer.
« Reply #7 on: January 17, 2008 »
Use it if you want to :)
Shockwave ^ Codigos
Challenge Trophies Won: