Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

pics

BravoknightBravoknight Member Posts: 35
is there anyway i can take a pic, like a gif, or jpg and tell qbasic to show the pic on the output screen. if u dont understand what i mean then i can try to explain better, but please help

Comments

  • PrzemekG_PrzemekG_ Member Posts: 595
    Yes, there are libraries handling many format of pictures, for 2 years I have internet and I saw graphic libraries handling gif, bmp, jpg, pcx, tif, ico, dib, I know also 2 libraries able to play avi and flc movies.

    Try http://www.qbasic.com and http://www.qb45.com


  • alan_pollockalan_pollock Member Posts: 110
    If you're more interested in writing the code for yourself (for the learning experience), you can find file formats of these files on the web. Once knowing that, you can open and read and display the file using Qbasic itself without an external library.

    A search for "gif file format" produced the following link...
    http://www.daubnet.com/formats/GIF.html#BasicFileFormat

    You'll find additional file formats listed at that site as well.
    Have fun.

  • BASIC FriendBASIC Friend Member Posts: 354
    : If you're more interested in writing the code for yourself (for the learning experience), you can find file formats of these files on the web. Once knowing that, you can open and read and display the file using Qbasic itself without an external library.
    :
    : A search for "gif file format" produced the following link...
    : http://www.daubnet.com/formats/GIF.html#BasicFileFormat
    :
    : You'll find additional file formats listed at that site as well.
    : Have fun.
    :
    :
    Yeah! Knowing a file foramt is very helpful. Learn as many of the ones you have come across that you can. I have a qbasic (and a moonrock one as well) program that creates bitmaps. I have tried to come up with a bitmap loader, but the graphics screens available weren't up to handling 24 bits at 640 by 480, but I could come up with black and white at 320 by 240. I didn't get into using the SVGA libraries though, or I could have done it.

    Things to know about .BMP:

    scan lines start at the bottom of the picture not the top.
    the 24 bit pixel isn't RGB, but BGR.
    The header can be loaded directly from the file into a struct(oops, TYPE in QB), and written to the file as such.
    You will need to translate the 24 bits to a color number that QB understands.

  • PrzemekG_PrzemekG_ Member Posts: 595
    For you it's BGR but for the computer it's RGB
    Try :
    [code]
    dim c$ as string * 1
    dim d$ as string * 1
    b% = 100
    a% = &hAAFF
    ptr% = VarPtr(b%)
    DEF SEG = VARSEG(b%)

    POKE ptr%, a%
    PEEK ptr%, c$
    PEEK ptr% + 1, d$
    print hex$(asc(c$)) + " " + hex$(asc(d$))
    [/code]
    as I know the result should be "FF AA"
    The computer store (in memory and on disk) all bytes of a numeric value from right to left
    So :
    VAR TYPE VAR SIZE YOU ENTER IN THE MEMORY
    integer 2 bytes AA BB BB AA
    long 4 bytes FF AA BB CC CC BB AA FF

    If you know assembler language, I always have a problem when
    [code]
    mov ax, 0xAF05
    [/code]
    I never know if ah=AF or ah=05


    SO a R=AA G=BB B=CC (RGB) in the memory is always stored as
    B=CC G=BB R=AA, the problem is gone with 32 bit graphics
    (you read a long value and it's the true color ;D)
  • BASIC FriendBASIC Friend Member Posts: 354
    [b][red]This message was edited by the BASIC Friend at 2002-3-4 10:47:44[/red][/b][hr]
    mov ax, 0xAF05
    I'd have a problem with that too. 0xAF05 is C. 0AF05h is what most assemblers recognize. 05h should be in AL and AFh should be in AH.

    When I read or write the BGR numbers in QB I put them in a string thats 3 bytes long. If i was to read it into a long, QB would read 4 bytes not 3. So in the string it is BGR. The end of the scanlines also always end on a double word, so I have to keep that in mind also.

    Also the RGB is not one number, but 3. The blue value is separate from the red value. When calculating with these numbers you need to keep that in mind. Like to average 2 colors you cant add the 2 rgb together and divide by two. You add the two red bytes, divide that by two, add the two green bytes, divide that by two, then add the two blue bytes together then divide that by two. put those 3 bytes together and you have the average.
    [code]
    function BGRAVE$(BGR1$, BGR2$)
    BGR3$ = ""
    FOR i% = 1 TO 3
    BGR3$ = BGR3$ + CHR$((ASC(MID$(BGR1$,i%,1)) + ASC(MID$(BGR2$, i%, 1))) / 2)
    NEXT i%
    BGRAVE$ = BGR3$
    END FUNCTION
    [/code]
    I think that's right, I haven't tested it.

    : For you it's BGR but for the computer it's RGB
    : Try :
    : [code]
    : dim c$ as string * 1
    : dim d$ as string * 1
    : b% = 100
    : a% = &hAAFF
    : ptr% = VarPtr(b%)
    : DEF SEG = VARSEG(b%)
    :
    : POKE ptr%, a%
    : PEEK ptr%, c$
    : PEEK ptr% + 1, d$
    : print hex$(asc(c$)) + " " + hex$(asc(d$))
    : [/code]
    : as I know the result should be "FF AA"
    : The computer store (in memory and on disk) all bytes of a numeric value from right to left
    : So :
    : VAR TYPE VAR SIZE YOU ENTER IN THE MEMORY
    : integer 2 bytes AA BB BB AA
    : long 4 bytes FF AA BB CC CC BB AA FF
    :
    : If you know assembler language, I always have a problem when
    : [code]
    : mov ax, 0xAF05
    : [/code]
    : I never know if ah=AF or ah=05
    :
    :
    : SO a R=AA G=BB B=CC (RGB) in the memory is always stored as
    : B=CC G=BB R=AA, the problem is gone with 32 bit graphics
    : (you read a long value and it's the true color ;D)
    :



  • PrzemekG_PrzemekG_ Member Posts: 595
    [b][red]This message was edited by the PrzemekG_ at 2002-3-7 3:27:29[/red][/b][hr]
    But now I know when I do
    [code]
    mov ax, 4C00h
    int 21h
    [/code]
    (The interupt to end my program) ah=4C and al0 becose the interupt sub function is in AH


  • Chris BrownChris Brown USAMember Posts: 4,624 ✭✭

    ______ || http://forcoder.org || free video tutorials and ebooks about ( Assembly Java Python R C# C++ Scratch Delphi Visual Basic .NET Swift MATLAB C Go Ruby Perl PL/SQL Objective-C Visual Basic JavaScript PHP Logo Ada Kotlin Prolog Clojure ABAP Julia Rust Crystal ML Fortran Scala SAS Scheme FoxPro LabVIEW Erlang Hack Bash Awk Lua F# Dart Apex Lisp D Transact-SQL COBOL VBScript Alice ) _____________

Sign In or Register to comment.