Large BMPs.

Up to LB4 we had problems getting high-resolution, as 'getbmp' only gets what is visible on screen.

Francesco showed an example several years back. Example below generates a 1800x1800 BMP.

If you open it in a browser rather than a LB graphics window you can see it either reduced to fit the browser page, or click on it for the full scale representation and scroll it.


LB code

'JB Spirograph v0.02 pre-alfa :) By Francesco
'Main purpose is to demonstrate the use of the function SaveGraphicBox.
'See below to read more about that function.
'The pic will be saved to the current dir with name "Spirograph.bmp"

'Here you can initialize bmp file settings
    ImageWidth=1800:ImageHeight=1800:xdpi=300:ydpi=300:FileName$="Spirograph.bmp"

'Open 600x600 window and (ImageWidth)x(ImageHeight) graphicbox
    nomainwin
    WindowWidth=600:WindowHeight=600
    UpperLeftX=(DisplayWidth-WindowWidth)/2:UpperLeftY=(DisplayHeight-WindowHeight)/2
    graphicbox #w.g,0,0,ImageWidth,ImageHeight
    open "JB Spirograph v0.01 by Francesco" for window_nf as #w
    #w "trapclose [quit]"

'Initialize random values for the epicycloid
    x0=ImageWidth/2:y0=ImageHeight/2:r1=0:r2=0:p=0:da=1:i=x0:if x0>y0 then i=y0
    t=int(i/50):if t<5 then t=5
    while (r1+r2+p)abs(r2) then t=abs(r2)
    for i=t to 1 step -1
        if ((abs(r1) mod i)=0)and((abs(r2) mod i)=0) then
            if i>1 then n=int(360*abs(r2)/i):i=0
            if i=1 then n=int(360*abs(r2)/3)
        end if
    next

'Here you can re-initialize the values of the spirograph.
'Uncomment next lines and set your values
'or they will be (reasonably) random.

'r1 = 60    '(pixels) radius of main circle
'r2 = 60    '(pixels) radius of second circle
'p  = 60    '(pixels) offset of drawing point relative to 2nd circle
'da = 1     '(degrees) increment of the angle (resolution)
'n  = 34560 '(decimal) number of points to calculate

'Draw epicycloid
    print #w.g,"down;place 0 0;color white;backcolor white"
    print #w.g,"boxfilled ";ImageWidth;" ";ImageHeight
    print #w.g,"flush;color black"
    a=0
    print #w.g,"place ";x0+r1+r2+p;" ";y0
    for i = 1 to n
        ar=asn(1)/90*a
        x=int((r1+r2)*cos(ar)+p*cos((r1+r2)*ar/r2))
        y=int((r1+r2)*sin(ar)+p*sin((r1+r2)*ar/r2))
        print #w.g,"goto ";x0+x;" ";y0+y
        a=a+da
    next
    print #w.g,"flush"

'Call SaveGraphicBox function, show result and exit
    t=SaveGraphicBox(FileName$,"#w.g",0,0,ImageWidth,ImageHeight,xdpi,ydpi)
    run "rundll32.exe C:\Windows\system32\shimgvw.dll,ImageView_Fullscreen "+DefaultDir$+"\"+FileName$
    close #w
    end

'****************************************************************************************************
'*  SaveGraphicBox saves part of a graphicbox to a bmp file to the default dir path.
'*  This function can grab and save the bitmap of very large graphicboxes while getbmp+bmpsave
'*  can grab and save only visible parts of them, thus being limited by the size of the desktop.
'*  This function moves the graphicbox and grabs it divided in many small bmp files and then
'*  merges them to single large bmp file. The graphicbox must be opened in a "window" type window.
'*
'*  Parameters:
'*  FileName$:  name of the bmp file
'*  boxHandle$: handle of the graphicbox
'*  xStart:     x of upper left corner of the portion to grab
'*  yStart:     y of upper left corner of the portion to grab
'*  xSize:      horizontal size in pixels of the portion to grab
'*  ySize:      vertical size in pixels of the portion to grab
'*  xdpi:       horizontal dpi that will be stored in bmp file header
'*  ydpi:       vertical dpi that will be stored in bmp file header
'****************************************************************************************************
function SaveGraphicBox(FileName$,boxHandle$,xStart,yStart,xSize,ySize,xdpi,ydpi)
    SaveGraphicBox=0:winHandle$=left$(boxHandle$,instr(boxHandle$,".")-1)
    nx=1+int((xSize-1)/500):ny=1+int((ySize-1)/500)
    ly=-1*yStart:nt=1:yS=ySize
    for i=1 to ny
        lx=-1*xStart:xS=xSize
        for j=1 to nx
            dx=500:if xS<500 then dx=xS
            dy=500:if yS<500 then dy=yS
            print #boxHandle$,"locate ";lx;" ";ly;" ";500-1*lx+2;" ";500-1*ly+2
            print #winHandle$,"refresh":print #boxHandle$,"flush"
            print #boxHandle$,"getbmp bmp ";-1*lx;" ";-1*ly;" ";dx;" ";dy
            bmpsave "bmp","SGBtemp"+right$("00"+str$(nt),3)+".bmp"
            lx=lx-500:xS=xS-500:nt=nt+1
        next
        ly=ly-500:yS=yS-500
    next
    print #boxHandle$,"locate 0 0 ";WindowWidth;" ";WindowHeight
    print #winHandle$,"refresh":print #boxHandle$,"flush"
    open "SGBtemp001.bmp" for input as #1:h$=input$(#1,14)
    hlen=asc(mid$(h$,11,1))+256*asc(mid$(h$,12,1))+256*256*asc(mid$(h$,13,1))+256*256*256*asc(mid$(h$,14,1))
    h$=h$+input$(#1,hlen-14):close #1
    nt=1:bmlen=0
    for i=1 to ny
        for j=1 to nx
            open "SGBtemp"+right$("00"+str$(nt),3)+".bmp" for input as #1:t$=input$(#1,6):close #1
            l=asc(mid$(t$,3,1))+256*asc(mid$(t$,4,1))+256*256*asc(mid$(t$,5,1))+256*256*256*asc(mid$(t$,6,1))
            bmlen=bmlen+l-hlen:nt=nt+1
        next
    next
    pixlen=int(bmlen/(xSize*ySize))
    open FileName$ for output as #1:n=int(bmlen/1000)
    print #1,h$;
    for i=1 to n:print #1,space$(1000);:next:print #1,space$(bmlen-n*1000);
    close #1
    open FileName$ for binary as #1:actualseek=hlen
    t=lof(#1):seek #1,2:for i=1 to 4:print #1,chr$(t and 255);:t=t/256:next
    t=xSize:seek #1,18:for i=1 to 4:print #1,chr$(t and 255);:t=t/256:next
    t=ySize:seek #1,22:for i=1 to 4:print #1,chr$(t and 255);:t=t/256:next
    t=bmlen:seek #1,34:for i=1 to 4:print #1,chr$(t and 255);:t=t/256:next
    t=int(xdpi*(100/2.54)):seek #1,38:for i=1 to 4:print #1,chr$(t and 255);:t=t/256:next
    t=int(ydpi*(100/2.54)):seek #1,42:for i=1 to 4:print #1,chr$(t and 255);:t=t/256:next
    for i=ny to 1 step -1
        t=0
        for j=1 to nx
            nt=(i-1)*nx+j:open "SGBtemp"+right$("00"+str$(nt),3)+".bmp" for input as #2
            t$=input$(#2,hlen)
            w=asc(mid$(t$,19,1))+256*asc(mid$(t$,20,1))+256*256*asc(mid$(t$,21,1))+256*256*256*asc(mid$(t$,22,1))
            h=asc(mid$(t$,23,1))+256*asc(mid$(t$,24,1))+256*256*asc(mid$(t$,25,1))+256*256*256*asc(mid$(t$,26,1))
            for k=1 to h:seek #1,actualseek+t+(k-1)*xSize*pixlen:print #1,input$(#2,w*pixlen):next
            close #2
            t=t+w*pixlen
        next
        actualseek=loc(#1)
    next
    close #1
    nt=1:for i=1 to ny:for j=1 to nx:kill "SGBtemp"+right$("00"+str$(nt),3)+".bmp":nt=nt+1:next:next
end function



[quit]
    close #w
    end