PROGRAM JIMAGE!       Example image.f

! Code converted using TO_F90 by Alan Miller
! Date: 2001-03-15  Time: 00:43:18

USE JAPI


INTEGER :: i,breite,hoehe

INTEGER :: frame,menubar,FILE,invert,obj,canvas,image
INTEGER,dimension(131072 ) :: r,g,b
  
CALL j_setdebug(0)

IF( .NOT. j_start()) THEN
  PRINT*, "can't connect to JAPI server"
  GO TO 20
END IF

image  = j_loadimage("images/mandel.gif")
breite = j_getwidth(image)
hoehe  = j_getheight(image)

print*, hoehe,breite

frame   = j_frame("Bilder")
menubar = j_menubar(frame)
FILE    = j_menu(menubar,"File")
invert  = j_menuitem(FILE,"Invert")

canvas  = j_canvas(frame,breite,hoehe)
CALL j_drawimage(canvas,image,0,0)
CALL j_setpos(canvas,10,60)

CALL j_show(frame)
CALL j_pack(frame)

NEXTACTION: DO
      obj=j_nextaction()

IF(obj == frame) EXIT NEXTACTION

IF(obj == invert) THEN
  CALL j_getimagesource(canvas,0,0,breite,hoehe,r,g,b)
  DO i=0,breite*hoehe
    r(i) = 255-r(i)
    g(i) = 255-g(i)
    b(i) = 255-b(i)
  END DO
  CALL j_drawimagesource(canvas,0,0,breite,hoehe,r,g,b)
END IF

END DO NEXTACTION

20      CONTINUE
CALL j_quit()

END PROGRAM JIMAGE
