放物変換

 投稿者:しばっち  投稿日:2015年 5月30日(土)22時06分43秒
  !'放物変換
FILE GETNAME F$,"BMP,JPG,GIF,PNGファイル|*.BMP;*.JPG;*.GIF;*.PNG"
CALL PICTURELOAD(F$,XSIZE,YSIZE)
DIM M(0 TO XSIZE-1,0 TO YSIZE-1)
ASK PIXEL ARRAY (0,0) M
!'放物変換
!' X'=X+A*Y^2
!' Y'=Y+B*X^2
LET A=1/XSIZE
LET B=1/YSIZE
LET XA=XSIZE+A*(YSIZE/2)^2
LET YA=YSIZE+B*(XSIZE/2)^2
LET MODE=0
SELECT CASE MODE
CASE 0
   CALL GINIT(INT(XA),INT(YA))
   FOR YS=0 TO YSIZE-1 STEP .5
      LET Y=YS-YSIZE/2
      FOR XS=0 TO XSIZE-1 STEP .5
         LET X=XS-XSIZE/2
         LET XX=X+A*Y^2
         LET YY=Y+B*X^2
         LET C=M(INT(XS),INT(YS))
         CALL RGB(C,RR,GG,BB)
         CALL PSET(XX+XSIZE/2,YY+YSIZE/2,RR,GG,BB)
      NEXT XS
   NEXT YS
CASE 1
   CALL GINIT(XSIZE,INT(YA))
   FOR YS=0 TO YSIZE-1 STEP .5
      LET Y=YS-YSIZE/2
      FOR XS=0 TO XSIZE-1 STEP .5
         LET X=XS-XSIZE/2
         LET XX=X
         LET YY=Y+B*X^2
         LET C=M(INT(XS),INT(YS))
         CALL RGB(C,RR,GG,BB)
         CALL PSET(XX+XSIZE/2,YY+YSIZE/2,RR,GG,BB)
      NEXT XS
   NEXT YS
CASE 2
   CALL GINIT(INT(XA),YSIZE)
   FOR YS=0 TO YSIZE-1 STEP .5
      LET Y=YS-YSIZE/2
      FOR XS=0 TO XSIZE-1 STEP .5
         LET X=XS-XSIZE/2
         LET XX=X+A*Y^2
         LET YY=Y
         LET C=M(INT(XS),INT(YS))
         CALL RGB(C,RR,GG,BB)
         CALL PSET(XX+XSIZE/2,YY+YSIZE/2,RR,GG,BB)
      NEXT XS
   NEXT YS
END SELECT
END

EXTERNAL SUB RGB(X,R,G,B)
LET B=MOD(INT(X/65536),256)
LET G=MOD(INT(X/256),256)
LET R=MOD(X,256)
END SUB

EXTERNAL SUB GINIT(XSIZE,YSIZE)
SET BITMAP SIZE XSIZE,YSIZE
SET COLOR MODE "NATIVE"
CLEAR
SET POINT STYLE 1
SET WINDOW 0,XSIZE-1,YSIZE-1,0
END SUB

EXTERNAL SUB PSET(X,Y,R,G,B)
SET COLOR COLORINDEX(R/255,G/255,B/255)
PLOT POINTS:X,Y
END SUB

EXTERNAL SUB PICTURELOAD(N$,XSIZE,YSIZE)
SET COLOR MODE "NATIVE"
CLEAR
SET POINT STYLE 1
IF N$="" THEN STOP
GLOAD N$
LET XSIZE=PIXELX(1)+1
LET YSIZE=PIXELY(1)+1
SET BITMAP SIZE XSIZE,YSIZE
SET WINDOW 0,XSIZE-1,YSIZE-1,0
END SUB

 

戻る