I tried a direct export of the graphics surface to a .gif file and it appears to work. This may be a good solution.
I also tested PARRAY for colours, indicating not being set when X > 2048
I think there is a problem with the dimension (X limit) of the DIB interface.
Try this alternative:
!winapp 'resource.rc'
program testplot
! use mswin
include <clearwin.ins>
!
C_EXTERNAL WRITE_GRAPHICS_TO_GIF@ '__write_graphics_to_gif' (INSTRING,REF)
!
integer*4, parameter :: x_max = 3000 ! 2048 works
integer*4, parameter :: y_max = 3000 ! extended is ok
!
INTEGER WVM,HVM,VMHANDLE,FUNC,ICOLR, x,y,IX,IY,MODE,IERCODE,NBPP, iopen,ierr
CHARACTER*1 PARRAY(3,x_max,y_max)
!
vmhandle = 11
WVM = x_max
HVM = y_max
IOPEN = CREATE_GRAPHICS_REGION@ ( VMHANDLE,WVM,HVM )
write (*,*) 'CREATE_GRAPHICS_REGION@ ( VMHANDLE,WVM,HVM ) =', iopen,' (1=success)'
!
ierr = select_graphics_object@ ( VMHANDLE)
write (*,*) 'select_graphics_object@ ( VMHANDLE) =', ierr,' (1=success)'
!
call use_rgb_colours@ (VMHANDLE, 1)
!
ICOLR = RGB@ (255,255,255)
call draw_filled_rectangle@ (0,0,WVM,HVM,ICOLR)
!
call write_graphics_to_gif@ ('blank_canvas.gif', iercode)
write (*,*) 'write_graphics_to_gif@ =',IERCODE,' (0=success)'
!
FUNC = 0
MODE = 0
x = 0
y = 0
IX = 0
IY = 0
call RECOVER_DIB_BLOCK@ (X,Y, & ! location on current graphics device (0,0)
PARRAY,WVM,HVM, & ! PARRAY array size
IX,IY, & ! location in PARRAY (1,1,1) ??; offset
WVM,HVM, & ! block size to transfer
FUNC, & ! 0 = REPLACE former pixel
MODE, & ! the dib palette should be used
IERCODE ) ! error code
write (*,*) 'RECOVER_DIB_BLOCK@ =',IERCODE,' (0=success)'
!
call test_DIB (PARRAY,WVM,HVM)
!
NBPP = 24
call PUT_DIB_BLOCK@ ( 'blank_canvas.jpg',PARRAY,WVM,HVM, X,Y, WVM,HVM, NBPP,IERCODE )
write (*,*) 'PUT_DIB_BLOCK@ =',IERCODE,' (0=success)'
!
ICOLR = RGB@ (127,127,127) ! dark grey box
ix = x_max/8
iy = y_max/8
call draw_filled_rectangle@ (ix, iy, x_max-ix, y_max-iy, ICOLR)
!
call graphics_write_mode@ (1)
ICOLR = RGB@ (0,0,255) ! blue border
ix = x_max/20
iy = y_max/20
call draw_line@ ( ix, iy, ix, y_max-iy, icolr)
call draw_line@ ( ix, y_max-iy, x_max-ix, y_max-iy, icolr)
call draw_line@ (x_max-ix, y_max-iy, x_max-ix, iy, icolr)
call draw_line@ (x_max-ix, iy, ix, iy, icolr)
!
ICOLR = RGB@ (255,255,0) ! bright red/green X
ix = x_max/4
iy = y_max/4
call draw_line@ (x_max-ix, iy, ix, y_max-iy, icolr)
call draw_line@ ( ix, iy, x_max-ix, y_max-iy, icolr)
!
ICOLR = RGB@ (127,127,0) ! dull red/green box
ix = 3*x_max/8
iy = 3*y_max/8
call draw_filled_rectangle@ (ix, iy, x_max-ix, y_max-iy, ICOLR)
!
call write_graphics_to_gif@ ('test_02.gif', iercode)
write (*,*) 'write_graphics_to_gif@ =',IERCODE,' (0=success)'
!
FUNC = 0
MODE = 0
IX = 0
IY = 0
call RECOVER_DIB_BLOCK@ (X,Y,PARRAY,WVM,HVM, IX,IY,WVM,HVM, FUNC,MODE,IERCODE )
write (*,*) 'RECOVER_DIB_BLOCK@ =',IERCODE,' (0=success)'
!
call test_DIB (PARRAY,WVM,HVM)
!
NBPP = 24
call PUT_DIB_BLOCK@ ( 'test_02.jpg',PARRAY,WVM,HVM, X,Y,WVM,HVM,NBPP,IERCODE )
write (*,*) 'PUT_DIB_BLOCK@ =',IERCODE,' (0=success)'
!
stop
end