Liberty BASIC Community Forum
« Search Results »

Welcome Guest. Please Login or Register.
Aug 29th, 2016, 03:51am


Rules|Home|Help|Search|Recent Posts|Notification

--Liberty BASIC Resources--
Liberty BASIC Community WikiSpace
Frequently Asked Questions
Bay Six Software Forum
Liberty BASIC Home Page
Carl Gundel's Blog
Official Liberty BASIC Support
Liberty BASIC Programmer's Encyclopedia
Liberty BASIC on Rosetta Code

Search Results

Total results: 10


 1   Open Source Projects / Re: QR Codes  on: Yesterday at 4:31pm
Started by CryptoMan | Post by tenochtitlanuk
Here's an example using the GDI+ code from LB encyclopedia. You'll need to change the font name if you you don't use LB under Linux/Wine.
User Image
Code:
    nomainwin

    WindowWidth  = 400
    WindowHeight = 500

    graphicbox #main.g,  50,  50, 302, 352

    open "Picture load" for window_nf as #main

    #main.g "down; fill 30 30 80; color red; backcolor 30 30 80  ; flush"
    #main.g "font Ubuntu 24"

    #main   "trapclose [quit.main]"

    open "gdiplus.dll" for dll as #gdip

    toEncode$   ="marklew1956"
    http$       ="http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl=" +toEncode$ +"&chld=H|0"
    result      = DownloadToFile( http$, "QR.png")

    timer 2000, [on0]
    wait
  [on0]
    timer 0

    if result <> 0 then print "Error downloading image.": end

    file$ ="QR.png"

    hBmp    =LoadImgFromFile( file$)
    if hBmp <>0 then
        loadbmp "pic", hBmp
        #main.g     "drawbmp pic 0 0; flush"
        unloadbmp "pic"    'Because LB doesnt delete it for us
        calldll #gdi32, "DeleteObject", hBmp as ulong, ret as ulong
        #main.g     "up; goto 60 340; down"
        #main.g     "\"; toEncode$
    else
        notice "Could not load the image file!"
    end if


    wait


[quit.main]
    close #gdip
    close #main
    end

function wchar$( string$)
    for i = 1 to len( string$)
        wchar$  =wchar$ +mid$( string$, i, 1) +chr$( 0)
    next i

    wchar$  =wchar$ +chr$( 0) +chr$( 0)
end function

function LoadImgFromFile( file$)
    struct dword, a as ulong
    gdistart$   =chr$( 1)

    for i = 1 to 15
        gdistart$   =gdistart$ +chr$( 0)
    next i

    calldll #gdip, "GdiplusStartup", dword as struct, gdistart$ as ptr, status as ulong

    token   =dword.a.struct

    if status <>0 then
        LoadImgFromFile   =0
    else
        wFileLoc$   =wchar$(file$)
        calldll #gdip, "GdipCreateBitmapFromFile", _
        wFileLoc$ as ptr, dword as struct, status as ulong
        hPic        =dword.a.struct

        if status <>0 then
            LoadImgFromFile =0
        else
            calldll #gdip, "GdipCreateHBITMAPFromBitmap", _
            hPic as ulong, dword as struct, 0 as ulong, status as ulong
            hBmp    =dword.a.struct

            if status <>0 then
                LoadImgFromFile =0
            else
                LoadImgFromFile =hBmp
            end if

            calldll #gdip, "GdipDisposeImage", hPic as ulong, ret as ulong
        end if

        calldll #gdip, "GdiplusShutdown", token as ulong, ret as ulong
    end if
end function

Function DownloadToFile( urlfile$, localfile$)
    open "URLmon" for dll as #url
    calldll #url, "URLDownloadToFileA",_
    0 as long,_         'null
    urlfile$ as ptr,_   'url to download
    localfile$ as ptr,_ 'save file name
    0 as long,_         'reserved, must be 0
    0 as long,_         'callback address, can be 0
    DownloadToFile as ulong  '0=success
    close #url
end function
 


When I tried the ( should be easier) calling of ImageMagick it failed on my Linux machine and I don't have a MS Windows machine here to try it.
Does anyone see why
Code:
    IM$         ="identify " +chr$( 34) +"/media/john/Stick2G/QR.png" +chr$( 34) +" > " +chr$( 34) +"/media/john/Stick2G/identify.txt" +chr$( 34)
    '   NB  identify "/media/john/Stick2G/QR.png" > "/media/john/Stick2G/identify.txt" works from terminal....
    run "cmd.exe /C "; chr$( 34); IM$; chr$( 34), HIDE
 

The command works from the Terminal, and other commands like
Code:
"dir > dir.txt" 
work happily...
It's been some time since I used the LB/ImageMagick combination.
 
  Reply Quote Notify of replies

 2   General Board / Re: Linux  on: Yesterday at 3:14pm
Started by mack | Post by tenochtitlanuk
Yes, if you are using the standard x86 processors. Install Wine in the usual way , and use it to install LB. But if you use Linux on ARM processors ( like my Raspberry Pi's) you don't have Wine.
I run LB on a Linux Mint installation, and don't turn on my old Windows PC from one month to the next! 99% of what programming I do ( see my website) is with LB on Linux.
 
  Reply Quote Notify of replies

 3   General Board / Linux  on: Yesterday at 1:13pm
Started by mack | Post by mack
Hi

Is it possible to use Liberty Basic while running Linux?

Robert
 
  Reply Quote Notify of replies

 4   Game and Graphic Programming / Re: were oh were has my bk gon is my back  on: Yesterday at 06:40am
Started by kevin | Post by kevin
thank you Mr Rod smiley
 
  Reply Quote Notify of replies

 5   Game and Graphic Programming / Re: were oh were has my bk gon is my back  on: Yesterday at 06:28am
Started by kevin | Post by Rod
You need to getbmp your drawn background then use the background Sprite command to have it drawn each drawsprite command. You will need to draw your score separately. Sprite byte series covers it all.
 
  Reply Quote Notify of replies

 6   Game and Graphic Programming / were oh were has my bk gon is my back  on: Yesterday at 06:21am
Started by kevin | Post by kevin
hi everyone
im paying around with sprites again
now in this code i attempt to draw a small grid for the sprite to move on

but wenever i click the mouse button to move the sprite it clears as if i put "cls"
Code:
'Run this program from the root LB directory
'so that it can find the sprite bitmaps.
nomainwin

    'this is the sprite bitmap
    loadbmp "smiley1", "sprites\smiley1.bmp"

    WindowHeight = 300:WindowWidth = 400

    'sprites can only appear in a graphics window or graphicbox
    open "sprite test" for graphics_nf_nsb as #wg
    print #wg, "when leftButtonMove [paint]"

    'trap the close event so the code can issue
    'the proper CLOSE and END commands
    #wg "trapclose [quit]"

    'add a sprite
    #wg "addsprite smiley smiley1"

    'give a location to sprite:
    #wg "spritexy smiley 30 40"

    'cause images to show
    #wg "drawsprites"


'wait for user input
#wg "down"
    #wg "set 50 50"
    #wg "goto 50 200"
    #wg "goto 350 200"
    #wg "goto 350 50"
    #wg "goto 50 50"
    #wg "up;goto 10 20;down"
    #wg "\score"
    print #wg, "flush";
wait


[paint]
   print #wg, "set "; MouseX; " "; MouseY
   print #wg, "spritexy smiley ";MouseX;" ";MouseY
   #wg "drawsprites"
   wait

[quit]
    unloadbmp "smiley1"
    close #wg:end

 


Kevin

 
  Reply Quote Notify of replies

 7   Open Source Projects / Re: QR Codes  on: Aug 27th, 2016, 4:20pm
Started by CryptoMan | Post by tenochtitlanuk
LB uses bmp image files. So it can't display a png directly. BUT...
To display a png you have several LB options- and I don't know how much experience you have.
One way is GDIplus. See GDIplus article
My way of choice on Linux ( or in the past MS Windows machines) is to install the free ImageMagick, which adds commands accessible from LB to size, load and alter in every conceivable way any image of any format. You'll find some examples on my website.
EDIT
ImageMagick

If this takes you out of your comfort zone I can try to create an example.
 
  Reply Quote Notify of replies

 8   Liberty BASIC Code / Re: Reading digital camera EXIF data  on: Aug 27th, 2016, 2:25pm
Started by tenochtitlanuk | Post by tsh73
doesn't work for Canon sad
(a510 and IXUS230)
 
  Reply Quote Notify of replies

 9   Open Source Projects / Re: QR Codes  on: Aug 27th, 2016, 1:07pm
Started by CryptoMan | Post by marklew1956
Thanks for the help! What I'm actually trying to do is get a text line and the qrcode on the same graphic window. What will be the simplest way to open the saved image and place it on a graphic window?
 
  Reply Quote Notify of replies

 10   Liberty BASIC Code / Reading digital camera EXIF data  on: Aug 26th, 2016, 3:19pm
Started by tenochtitlanuk | Post by tenochtitlanuk
Someone raised this on the forum and it encouraged me to have a play.
Many modern cameras store the image, a thumbnail version, and technical information BUT the format is 'flexible' and interpreted differently sometimes, and not always handled correctly when you edit the photo.
After a quick Google search I decided it was easiest to reverse-engineer some of my own photos. A hex editor showed where the plain-text xml data section was and I ended with this code.
No guarantee it will work on your camera. And photo-processors like The Gimp display the data anyway.
However it's got me thinking on a bit of data analysis and statistics- I've 16000 photos on Flickr to play with!
Code:
    filedialog "Input JPG", "*.jpg", fn$

    open fn$ for input as #inFile
        c$ =input$( #inFile, lof( #inFile))
    close #inFile

    while datum$ <>"999"
        read datum$ 
        if datum$ ="999" then wait
        strt        =instr( c$, datum$) +len( datum$)
        fin         =instr( c$, "</" +mid$( datum$, 2))

        dAbbrv$     =mid$( datum$, 7)
        value$      =mid$( c$, strt, fin -strt)
        if instr( value$, "<rdf") then value$ =""
        print dAbbrv$; tab( 35); "= "; value$
    wend

    wait

    end

data "<exif:Make>"
data "<exif:Model>"
data "<exif:Orientation>"
data "<exif:XResolution>"
data "<exif:YResolution>"
data "<exif:ResolutionUnit>"
data "<exif:DateTime>"
data "<exif:YCbCrPositioning>"
data "<exif:Copyright>"
data "<exif:Compression>"
data "<exif:XResolution>"
data "<exif:YResolution>"
data "<exif:ResolutionUnit>"
data "<exif:ExposureTime>"
data "<exif:FNumber>"
data "<exif:ISOSpeedRatings>"
data "<exif:ExifVersion>"
data "<exif:DateTimeOriginal>"
data "<exif:CompressedBitsPerPixel>"
data "<exif:ShutterSpeedValue>"
data "<exif:ApertureValue>"
data "<exif:ExposureBiasValue>"
data "<exif:MaxApertureValue>"
data "<exif:MeteringMode>"
DATA "999"
 

OUTPUT on one of my trusty old cameras..
Code:
Make>                             = EASTMAN KODAK COMPANY
Model>                            = KODAK DX7590 ZOOM DIGITAL CAMERA
Orientation>                      = Top-left
XResolution>                      = 230
YResolution>                      = 230
ResolutionUnit>                   = Inch
DateTime>                         =
YCbCrPositioning>                 = Centred
Copyright>                        =
Compression>                      = JPEG compression
XResolution>                      = 230
YResolution>                      = 230
ResolutionUnit>                   = Inch
ExposureTime>                     = 1/1000 sec.
FNumber>                          = f/5.0
ISOSpeedRatings>                  =
ExifVersion>                      = Exif Version 2.21
DateTimeOriginal>                 = 2015:11:14 06:32:11
CompressedBitsPerPixel>           =
ShutterSpeedValue>                = 9.90 EV (1/955 sec.)
ApertureValue>                    = 4.60 EV (f/4.9)
ExposureBiasValue>                = 0.00 EV
MaxApertureValue>                 = 3.50 EV (f/3.4)
MeteringMode>                     = Pattern
 

 
  Reply Quote Notify of replies


Rules|Home|Help|Search|Recent Posts|Notification



Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls