画像放射ぼかし

 投稿者:しばっち  投稿日:2020年 5月24日(日)14時32分24秒
  長さと楕円領域の大きさとその中心座標をスライドバーで指定します。
スライドバーを動かした後、グラフィックウィンドゥ内をマウスでクリックしてください。


OPTION BASE 0
FILE GETNAME N$,"BMP,JPG,GIF,PNGファイル|*.BMP;*.JPG;*.GIF;*.PNG"
CALL PICTURELOAD(N$,XSIZE,YSIZE)
DIM M(XSIZE-1,YSIZE-1),MM(XSIZE-1,YSIZE-1)
ASK PIXEL ARRAY(0,0) M
LOCATE VALUE NOWAIT(1),RANGE 1 TO MIN(XSIZE,YSIZE)/5,AT 10:LENGTH
LOCATE VALUE NOWAIT(2),RANGE 0 TO XSIZE-1,AT XSIZE/2:X0
LOCATE VALUE NOWAIT(3),RANGE 0 TO YSIZE-1,AT YSIZE/2:Y0
LOCATE VALUE NOWAIT(4),RANGE 1 TO XSIZE/2,AT XSIZE/10:XR
LOCATE VALUE NOWAIT(5),RANGE 1 TO YSIZE/2,AT YSIZE/10:YR
DO
   CLEAR
   SET TEXT HEIGHT YSIZE/10
   SET COLOR COLORINDEX(0,0,0)
   SET TEXT BACKGROUND "OPAQUE"
   SET TEXT JUSTIFY "CENTER" , "TOP"
   PLOT TEXT ,AT XSIZE/2,YSIZE/2 :"処理中"
   LET LENGTH=INT(LENGTH)
   LET X0=INT(X0)
   LET Y0=INT(Y0)
   LET XR=INT(XR)
   LET YR=INT(YR)
   FOR Y=0 TO YSIZE-1
      SET TEXT JUSTIFY "LEFT" , "TOP"
      PLOT TEXT ,AT 0,0 :USING$("###.#",Y/(YSIZE-1)*100)&"%"
      FOR X=0 TO XSIZE-1
         IF GetKeyState(32)<0 OR GetKeyState(13)<0 OR GetKeyState(27)<0 THEN STOP
         IF ((X-X0)/XR)^2+((Y-Y0)/YR)^2>1 THEN
            LET RR=INT(SQR((X-X0)^2+(Y-Y0)^2))
            IF X+X0-XS=0 THEN
               IF Y-Y0>0 THEN LET TH=PI/2 ELSE LET TH=1.5*PI
            ELSE
               LET TH=ANGLE(X-X0,Y-Y0)
            END IF
            LET R1=0
            LET G1=0
            LET B1=0
            LET N=0
            FOR I=0 TO LENGTH-1
               IF GetKeyState(32)<0 OR GetKeyState(13)<0 OR GetKeyState(27)<0 THEN STOP
               LET XX=X0+INT((RR+I)*COS(TH))
               LET YY=Y0+INT((RR+I)*SIN(TH))
               IF XX>=0 AND XX<=XSIZE-1 AND YY>=0 AND YY<=YSIZE-1 THEN
                  LET CC=M(XX,YY)
                  CALL RGB(CC,R,G,B)
                  LET R1=R1+R
                  LET G1=G1+G
                  LET B1=B1+B
                  LET N=N+1
               ELSE
                  EXIT FOR
               END IF
            NEXT I
            IF N>0 THEN LET MM(X,Y)=SETRGB(INT(R1/N),INT(G1/N),INT(B1/N))
         ELSE
            LET MM(X,Y)=M(X,Y)
         END IF
      NEXT X
   NEXT Y
   MAT PLOT CELLS , IN 0,0; XSIZE-1,YSIZE-1:MM
   DO   !'ウェイト。マウスでウィンドゥ内をクリックする。
      IF GetKeyState(32)<0 OR GetKeyState(13)<0 OR GetKeyState(27)<0 THEN STOP
      MOUSE POLL X,Y,LL,RR
      LOCATE VALUE NOWAIT(1):LENGTH
      LOCATE VALUE NOWAIT(2):X0
      LOCATE VALUE NOWAIT(3):Y0
      LOCATE VALUE NOWAIT(4):XR
      LOCATE VALUE NOWAIT(5):YR
   LOOP WHILE LL=0 AND RR=0
LOOP
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 FUNCTION SETRGB(R,G,B)
LET R=MIN(255,MAX(R,0))
LET G=MAX(0,MIN(G,255))
LET B=MAX(0,MIN(B,255))
LET SETRGB=B*65536+G*256+R
END FUNCTION

EXTERNAL SUB PICTURELOAD(N$,XSIZE,YSIZE)
CLEAR
SET COLOR MODE "NATIVE"
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
 

戻る