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
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.
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...
You'll find additional file formats listed at that site as well.
: 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...
: 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.
For you it's BGR but for the computer it's RGB
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$))
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
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
mov ax, 0xAF05
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)
[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.
function BGRAVE$(BGR1$, BGR2$)
BGR3$ = ""
FOR i% = 1 TO 3
BGR3$ = BGR3$ + CHR$((ASC(MID$(BGR1$,i%,1)) + ASC(MID$(BGR2$, i%, 1))) / 2)
BGRAVE$ = BGR3$
I think that's right, I haven't tested it.
: For you it's BGR but for the computer it's RGB
: Try :
: 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$))
: 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
: mov ax, 0xAF05
: 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)
[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
mov ax, 4C00h
(The interupt to end my program) ah=4C and al0 becose the interupt sub function is in AH
It looks like you're new here. If you want to get involved, click one of these buttons!
Assembly Code Share
Getting started in assembly
C and C++
C/C++ on Linux/Unix
C/C++ Windows API
C++ Game Development
Delphi and Kylix
Java Server Pages
Access databases and VB
Advance Visual Basic
DirectX Game dev
Newbie Game Programmers
Cooling & Overclocking
Database & SQL
Sound & Music
FreeLance Software City
C# & VB.NET School Support
Join the Team
Comments on this site
New programming languages
Off topic board
Mobile & Wireless
Operating Systems & Platforms
Witsbits Go Cloud
Embedded / RTOS
Windows CE & Pocket PC
Networking And Security
Windows 2003 Server
RUP & UML
Quality & Testing
Active Server Pages
HTML & WEB-Design
Mobile Internet & Messaging
WEB-Services / SOAP
In this Discussion