Oxygen Basic
Programming => Example Code => Topic started by: Peter on May 13, 2011, 08:50:54 AM
-
Deleted
-
Hi Peter,
You can only use simple equates at present.
I have not hooked up the evaluator for doing arithmetic on dim sizes. I will try to get this set up for the next release.
Charles
-
Peter,
I have now implemented evaluation of equates for arrays. So you should now be able to specify:
% width 640
% height 480
% pixelbytes 4
...
dim as byte [width*height*pixelbytes]
I have just posted the update (Oxygen in-progress version)
Charles
-
I like the evaluation of equates in arrays Charles, nice addition.
Peter, raw files are simple to load but are usually not the preferred format as they are not compressed.
You might want to start using jpgs or if you want alpha channels also then png formats.
Charles has examples where he uses gdi+ for image loading, I have not tinkered or gotten that far yet in my studies of oxygen,
but you might want to look at those.
-
Hi Kent,
I would say in favour of BMP and RAW files, if they have significant areas of flat color, they will zip very efficently even if they eat up your disk space uncompressed :)
One problem with RAW files is hat every digital camera maker in the world has their own unique specification. RAW has no standard at all.
Charles
-
I'm porting some BMP stuff - this info is useful for loading BMP textures directly or creating BMP files directly without going through GDI.
Charles
'===============
'bmp file loader
'===============
type BmpMapHeader
short bfType
long bfSize
short bfReserved1
short bfReserved2
long bfOffBits
long biSize
long biWidth
long biHeight
short biPlanes
short biBitCount
long biCompression
long biSizeImage
long biXPelsPerMeter
long biYPelsPerMeter
long biClrUsed
long biClrImportant
end type
string bmpfile="t.bmp" 'choose your file
string bmpdata=""
getfile bmpfile,bmpdata
sys le=len bmpdata
if le=0 then print "no data" : jmp fwd done
'
BmpMapHeader *d : @d = *bmpdata
'---------------------
'DISPLAY HEADER VALUES
'=====================
'
#if 1 '0/1 excl/incl
'
'capture signature to string
'---------------------------
'
string n=" "
**n=?d
n=left n,2
'
string cr=chr(13)+chr(10)
string tab=chr(9)
string pr="BMP HEADER DATA FOR " bmpfile cr cr
def p pr=pr+ %1 tab %2 cr
'
'------------------------------------------
p "Signature: " n
p "File Size: " d.bfSize
p "Bit data offset : " d.bfOffBits
p "Header size: " d.bisize
p "Image Width: " d.biWidth
p "Image Height: " d.biHeight
p "Bit planes: " d.biPlanes
p "Bits per pixel: " d.biBitCount
p "Compression: " d.biCompression
p "Size of Image: " d.biSizeImage
p "Xpixels per metre:" d.biXPelsPerMeter
p "Ypixels per metre:" d.biYPelsPerMeter
p "Colours used: " d.biClrUsed
p "Colours important:" d.biClrImportant
'------------------------------------------
print pr
'
#endif 'display header values
'----------------
'ACCESS TO PIXELS
'================
type pixel byte r,g,b
pixel *pix : @pix = *BmpData + d.bfOffBits
'print pix[1].r
'-------------
'SAVE BMP FILE
'=============
'putfile "s.bmp",BmpData
'====
done:
'====
BmpData=""
'=====
'NOTES
'=====
'----------------------------------------------------------------------------------------------------------
' BMP file formats
'
' The BITMAPFILEHEADER:
'----------------------------------------------------------------------------------------------------------
'start size name stdvalue purpose
'----------------------------------------------------------------------------------------------------------
'1 2 bfType 19778 must always be set to 'BM' to declare that this is a .bmp-file.
'3 4 bfSize ?? the size of the file in bytes.
'7 2 bfReserved1 0 must always be set to zero.
'9 2 bfReserved2 0 must always be set to zero.
'11 4 bfOffBits 1078 specifies the offset from the beginning of the file to the bitmap data.
'----------------------------------------------------------------------------------------------------------
'
'
' The BITMAPINFOHEADER:
'----------------------------------------------------------------------------------------------------------
'start size name stdvalue purpose
'----------------------------------------------------------------------------------------------------------
'15 4 biSize 40 size of the BITMAPINFOHEADER structure, in bytes.
'19 4 biWidth 100 width of the image, in pixels.
'23 4 biHeight 100 height of the image, in pixels.
'27 2 biPlanes 0 number of planes of the target device, must be set to zero.
'29 2 biBitCount 8 number of bits per pixel.
'31 4 biCompression 0 type of compression, usually set to zero (no compression).
'35 4 biSizeImage 0 size of the image data, in bytes. If there is no compression, it is valid to set this member to zero.
'39 4 biXPelsPerMeter 0 horizontal pixels per meter on the designated targer device, usually set to zero.
'43 4 biYPelsPerMeter 0 vertical pixels per meter on the designated targer device, usually set to zero.
'47 4 biClrUsed 0 number of colors used in the bitmap, if set to zero the number of colors is calculated using the biBitCount member.
'51 4 biClrImportant 0 number of color that are 'important' for the bitmap, if set to zero, all colors are important.
'----------------------------------------------------------------------------------------------------------
-
I was wondering, did you guys... Charles and Peter find something wrong with using GDI+ ? I was just curious.
If you want to port over more types, here is a great site for all file formats:
http://www.wotsit.org/list.asp?fc=1
-
GDI+ is really a sub-system intended for additional layers of abstraction in the MS scheme of things. It also uses GUIDs to access image codecs - a bit like COM. This makes it quite cumbersome to use directly. One is expect to use classes on the next layer up. But It is not as challenging as setting up Opengl :)
Charles