Something to fix ?

by Lisztfr (no login)

 
Hi,

Thanks for the tutorial, it runs nicely !

This was the first page i stumble upon :

http://www.petesqbsite.com/sections/tutorials/tuts/interrupts.html

But i get an error here (overflow)

Offset% = VAL("&H" + HEX$(320 * y%)) ' Hack to get integers bigger than 32767

Hint : load the source code to get the line breaks....and remove the "amp" stuff.


Here it is :

'$INCLUDE: 'qb.bi'

TYPE BMPHeaderType
id AS STRING * 2 'Should be "BM"
size AS LONG 'Size of the data
rr1 AS INTEGER '
rr2 AS INTEGER '
offset AS LONG 'Position of start of pixel data
horz AS LONG '
wid AS LONG 'Image width
hei AS LONG 'Image height
planes AS INTEGER '
bpp AS INTEGER 'Should read 8 for a 256 colour image
pakbyte AS LONG '
imagebytes AS LONG 'Width*Height
xres AS LONG '
yres AS LONG '
colch AS LONG '
ic AS LONG '
pal AS STRING * 1024 'Stored as <Blue, Green, Red, 0>
END TYPE

DIM inregs AS RegTypeX ' Data IN
DIM outregs AS RegTypeX ' Data OUT
DIM FileHandle AS INTEGER ' Handle used to reference the BMP file
DIM BMPHeader AS BmpHeaderType ' The BMP header

file$ = "demo.bmp" + CHR$(0) ' BMP file. DOS requires us to append a CHR$(0).

inregs.AX = &H3D00 ' Open the File
inregs.DS = VARSEG(file$) ' Segment address of the string
inregs.DX = SADD(file$) ' Offset address of the string (we use SADD
' when working with variable length strings)
CALL InterruptX(&H21, inregs, outregs)

IF outregs.FLAGS AND 1 THEN ' Check it opened ok
PRINT "Error opening >> " + file$
BEEP: END
END IF

FileHandle = outregs.AX ' Save the file handle

inregs.AX = &H3F00 ' Read in the header
inregs.BX = FileHandle
inregs.CX = 1078
inregs.DS = VARSEG(BMPHeader)
inregs.DX = VARPTR(BMPHeader)
CALL InterruptX(&H21, inregs, outregs)

SCREEN 13 ' Set dislay mode

a$ = BMPHeader.pal ' Change the palette
OUT &H3C8, 0
FOR i% = 1 TO 1024 STEP 4
b% = ASC(MID$(a$, i%, 1)) \ 4 'blue
g% = ASC(MID$(a$, i% + 1, 1)) \ 4 'green
r% = ASC(MID$(a$, i% + 2, 1)) \ 4 'red
OUT &H3C9, r%
OUT &H3C9, g%
OUT &H3C9, b%
NEXT

PixelBuffer$ = SPACE$(BMPHeader.wid)
iHeight% = BMPHeader.hei - 1
Segment% = &HA000 ' Address of SCREEN 13 memory

inregs.AX = &H3F00
inregs.BX = FileHandle
inregs.CX = BMPHeader.wid

FOR y% = iHeight% TO 0 STEP -1

Offset% = VAL("&H" + HEX$(320& * y%)) ' Hack to get integers bigger than 32767

inregs.DS = Segment%
inregs.DX = Offset%
CALL InterruptX(&H21, inregs, outregs)

NEXT y%

inregs.DS = 0 ' Close the file
inregs.DX = 0
inregs.AX = &H3E00
inregs.BX = FileHandle
CALL InterruptX(&H21, inregs, outregs)

SLEEP

=========

Thanks,

L

Posted on Jul 15, 2008, 5:59 AM

Respond to this message   

Return to Index

Response TitleAuthor and Date
There is no real fix for large images, but other changes are neededClippy on Jul 15
 *Thanks for answering, Ted, I haven't got a clue about this stuff :-PTheBOB on Jul 15
  Actually Antoni tried the PEEK stuff and it worked ;-)Clippy on Jul 15
Re: Something to fix ?Tim on Jul 15
 If you'd have looked at my corrections TimClippy on Jul 15
  Re: If you'd have looked at my corrections TimTim on Jul 15
   Sounds reasonable, so how would you recode the "hack"?Clippy on Jul 15
  Bitmap loader edited by 1998 VirtuaSoftLisztfr on Jul 16
   If I understand your question...TheBOB on Jul 16
    i'm using this to display a 8 bit bsaved bmpLisztfr on Jul 16
     You know, of course, that SCREEN 2 only has 2 attributes...TheBOB on Jul 16
      Just to display some numbers, eventually a watch..Lisztfr on Jul 16
       Try using a TYPE and dot variablesClippy on Jul 16
       What you may have to do...TheBOB on Jul 16
        Here's an example of a SCREEN 2 image processed as described above...TheBOB on Jul 16
         Raw formatLisztfr on Jul 16
          RAW is similar to Binary. I just uploaded a BSAVER programClippy on Jul 16
           RAW to DataLisztfr on Jul 18
            *Not sure about RAW, with .BMP's pad to 32-bit boundaries (mennonite?).TheBOB on Jul 18
          *Not familiar with RAW -- mennonite should be able to help you (post in main forum).TheBOB on Jul 16
           you don't want us to talk about raw images here?mennonite on Jul 17
            i don't have a font loader...Lisztfr on Jul 17
             You don't need no Front Loader man!Cheech on Jul 17
              Some nice fonts !!!Lisztfr on Jul 18
               Here are some more...TheBOB on Jul 18
                What files are needed with the Qbasics.bas program?Clippy on Jul 18
                 The font files are all included in the zips...TheBOB on Jul 18
                  Is there any chance to get é, è, à, ç, ù ..?Lisztfr on Jul 19
                Very cool !Lisztfr on Jul 19
                 Resizing isn't possible with bitmap fonts...TheBOB on Jul 19
        * This sounds like a great idea for Monochrome. I think I will make one!Clippy on Jul 16
        I made a Screen 12 to 2 program that uses your code BobClippy on Jul 19
         As I understand it...TheBOB on Jul 19
          HP 200lxLisztfr on Jul 20
           *Interesting -- thanks :-)TheBOB on Jul 20
            Screen shot with fonts !Lisztfr on Jul 20
             *Thanks -- lol -- first time I ever saw "Press any key to continue" in French!TheBOB on Jul 20
        Actually, your One Bit routine in Winbit works in Screen 2 also BobClippy on Jul 20
         *Hey, good to know -- I've never used SCREEN 2 (of course).TheBOB on Jul 20
          Here is my code for SCREEN 2 BSAVES (URL)Clippy on Jul 20
           *Nice work! You are officially the SCREEN 2 expert around here!TheBOB on Jul 20
            * As Elvis would say: "Thankyou very much"Clippy on Jul 20
             Some question with takes my sleep ...Lisztfr on Jul 21
              That probably won't apply to your palmtop...TheBOB on Jul 21
               I use a skin softener on my palmtops !Clippy on Jul 21
                *I tried your suggestion, but the images were all blurry after that.TheBOB on Jul 21
                 * Could be, but the palm screen might be better.Clippy on Jul 21
                  NerdsLisztfr on Jul 21
                   *Yeah, that's great. We're all familiar with it around here ;-)TheBOB on Jul 21
     Where are the color settings?Clippy on Jul 16
 * Also. You can load 4 BPP bitmaps in Screen 13Clippy on Jul 15

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement