Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Resizing Images???
#11
'this can be optimized a lot by using DDA
Code:
SUB StretchSprite (px%, py%, NewWid%, NewHei%, Sprite(), Buffer())

'px and py are the coordinates of the sprite
'Newwid and Newhei are the new dimensions of the sprite
'Sprite is a GET/PUT array
'Buffer is the virtual page
'uses 8.8 fixed point math for lil speed inside the IDE
'clipping supported
'Uses a Static array called scanline() for speed issues.

wid% = Sprite(0) \ 8
Hei% = Sprite(1)
xstep% = (wid% * 128 \ NewWid%)
ystep% = (Hei% * 128 \ NewHei%)

y% = py%
x% = px%
'Clip/Crop it
IF y% < 0 THEN
        CY = -y%
        NewHei% = NewHei% - CY
        y% = 0
        miny% = CY
ELSEIF y% > 199 THEN
        EXIT SUB
ELSE
        Ndy = y% + NewHei%
        IF Ndy > 199 THEN
                NewHei% = NewHei% - (Ndy - (200))
        END IF
END IF

IF x% < 0 THEN
        cx = -x%
        NewWid% = NewWid% - cx
        x% = 0
        minx% = cx
ELSEIF x% > 319 THEN
        EXIT SUB
ELSE
        Ndx = x% + NewWid%
        IF Ndx > 319 THEN
                NewWid% = NewWid% - (Ndx - 320)
        END IF
END IF

'ax=x
'bx=wid
'cx=y
'dx=hei


Vseg% = VARSEG(Buffer(0))
Voff% = VARPTR(Buffer(8))
SprSeg% = VARSEG(Sprite(0))
SprOff% = VARPTR(Sprite(2))
u& = 0
v& = 0
T20Mw = 320 - NewWid%
di& = Voff% + y% * 320& + x%        'start coords(DDA this)

v& = miny% * ystep%
minxstep& = minx% * xstep%

FOR y% = 0 TO NewHei% - 1
    u& = minxstep&
    ya = v& \ 128
    Temp& = ya * wid% + SprOff%
    Offset& = Temp&
    DEF SEG = SprSeg%
    FOR x% = 0 TO NewWid% - 1
        xa = u& \ 128
        Offset& = Temp& + xa
        Scanline%(x%) = PEEK(Offset&)
        u& = u& + xstep%
    NEXT x%
    DEF SEG = Vseg%
    FOR x% = 0 TO NewWid% - 1
        c% = Scanline(x%)
        IF c% THEN
            POKE di&, c%
        END IF
        di& = di& + 1
    NEXT x%
    v& = v& + ystep%
    di& = di& + T20Mw
NEXT y%

END SUB
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#12
Uhm this may sound stupid but what is DDA???
Reply
#13
i have several programs at home on scaling and that stuff... i'll have to dig it up when i get home.
Jumping Jahoolipers!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)