Revision history for KeyPgBload


Revision [23202]

Last edited on 2019-09-05 00:50:47 by fxm [only works in graphics mode]
Additions:
##**Bload**## must be called only if a graphics mode is initialized, else the program crashes.


Revision [21528]

Edited on 2016-08-13 04:36:40 by fxm [Corrected bad referring to 'Open']
Additions:
The error code returned by ##**Bload**## can be checked using ##[[KeyPgErr|Err]]## in the next line. The function version of ##**Bload**## returns directly the error code as a 32 bit ##[[KeyPgLong|Long]]##.
Deletions:
The error code returned by ##**Bload**## can be checked using ##[[KeyPgErr|Err]]## in the next line. The function version of ##**Open**## returns directly the error code as a 32 bit ##[[KeyPgLong|Long]]##.


Revision [21320]

Edited on 2016-04-06 03:01:05 by fxm [The error code returned can also be checked using Err()]
Additions:
The error code returned by ##**Bload**## can be checked using ##[[KeyPgErr|Err]]## in the next line. The function version of ##**Open**## returns directly the error code as a 32 bit ##[[KeyPgLong|Long]]##.


Revision [20829]

Edited on 2016-03-12 15:11:36 by fxm [Formatting]
Additions:







Revision [20066]

Edited on 2016-02-10 15:55:01 by DkLwikki [Update link format]
Additions:
Loads arbitrary data from a file created with ##[[KeyPgBsave|Bsave]]##, or a compatible BMP image file.
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Bload** ( [[KeyPgByref|byref]] //filename// [[KeyPgAs|as]] [[KeyPgConstQualifier|const]] [[KeyPgString|string]], [[KeyPgByval|byval]] //dest// [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]] = 0, [[KeyPgByval|byval]] //pal// [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]] = 0 ) [[KeyPgAs|as]] [[KeyPgLong|long]]
Returns zero (##0##) if successful, or a non-zero error code to indicate a failure. //[[ProPgErrorHandling|(throws a runtime error)]]//
##**Bload**## can be used to load image data or any other data from a file created with ##[[KeyPgBsave|Bsave]]##, and store that data in an array or paste it to the screen. If ##//dest//## is absent or null (##0##), the image data is pasted to the current graphics screen work page. Otherwise it is loaded as image data to the address given by ##//dest//##.
- New FB-like data files, saved with ##[[KeyPgBsave|Bsave]]## from FB code, containing "raw" data preceded by a 5-byte header, beginning with ##&HFE##. There is no 64 ""KiB"" limit with this format
- BMP image files, supports a subset of valid ("Windows") .BMP files, beginning with ##"BM"##, saved from FB code with ##[[KeyPgBsave|Bsave]]##, or created / saved in a compatible format using a graphics editor / converter.
When using one of the 2 "non-BMP" file formats to save images, the image files must have been created with ##[[KeyPgBsave|Bsave]]## in the same graphics screen mode as it is being loaded into. When using the BMP file format, this restriction doesn't apply.
##**Bload**## throws one of the following [[ProPgErrorHandling|runtime errors]]:
- ##[[KeyPgBsave|Bsave]]##
- ##[[KeyPgPalette|Palette]]##
- ##[[KeyPgImagecreate|ImageCreate]]##
- ##[[KeyPgImageDestroy|ImageDestroy]]##
- [[GfxInternalFormats|Internal Graphics Formats]]
Deletions:
Loads arbitrary data from a file created with ##[[KeyPgBsave Bsave]]##, or a compatible BMP image file.
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Bload** ( [[KeyPgByref byref]] //filename// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]], [[KeyPgByval byval]] //dest// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0, [[KeyPgByval byval]] //pal// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgLong long]]
Returns zero (##0##) if successful, or a non-zero error code to indicate a failure. //[[ProPgErrorHandling (throws a runtime error)]]//
##**Bload**## can be used to load image data or any other data from a file created with ##[[KeyPgBsave Bsave]]##, and store that data in an array or paste it to the screen. If ##//dest//## is absent or null (##0##), the image data is pasted to the current graphics screen work page. Otherwise it is loaded as image data to the address given by ##//dest//##.
- New FB-like data files, saved with ##[[KeyPgBsave Bsave]]## from FB code, containing "raw" data preceded by a 5-byte header, beginning with ##&HFE##. There is no 64 ""KiB"" limit with this format
- BMP image files, supports a subset of valid ("Windows") .BMP files, beginning with ##"BM"##, saved from FB code with ##[[KeyPgBsave Bsave]]##, or created / saved in a compatible format using a graphics editor / converter.
When using one of the 2 "non-BMP" file formats to save images, the image files must have been created with ##[[KeyPgBsave Bsave]]## in the same graphics screen mode as it is being loaded into. When using the BMP file format, this restriction doesn't apply.
##**Bload**## throws one of the following [[ProPgErrorHandling runtime errors]]:
- ##[[KeyPgBsave Bsave]]##
- ##[[KeyPgPalette Palette]]##
- ##[[KeyPgImagecreate ImageCreate]]##
- ##[[KeyPgImageDestroy ImageDestroy]]##
- [[GfxInternalFormats Internal Graphics Formats]]


Revision [17477]

Edited on 2015-04-01 10:54:03 by DkLwikki [integer => long]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Bload** ( [[KeyPgByref byref]] //filename// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]], [[KeyPgByval byval]] //dest// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0, [[KeyPgByval byval]] //pal// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgLong long]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Bload** ( [[KeyPgByref byref]] //filename// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]], [[KeyPgByval byval]] //dest// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0, [[KeyPgByval byval]] //pal// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgInteger integer]]


Revision [17451]

Edited on 2015-03-02 06:24:28 by CountingPine [width/height should be 32-bit vars]
Additions:
dim as long filenum, bmpwidth, bmpheight
Deletions:
dim as integer filenum, bmpwidth, bmpheight


Revision [16346]

Edited on 2012-09-21 22:22:53 by CountingPine [Add palette loading example]
Additions:
screenres 640, 480, 8 '' 8-bit palette graphics mode
dim pal(0 to 256-1) as integer '' 32-bit integer array with room for 256 colors
'' load bitmap to screen, put palette into pal() array
bload "picture.bmp", , @pal(0)
windowtitle "Old palette"
'' set new palette from pal() array
palette using pal(0)
windowtitle "New palette"
{{fbdoc item="filename" value="examples/manual/gfx/bload4.bas"}}%%(freebasic)


Revision [15133]

Edited on 2011-07-31 14:34:41 by StWwikki [Add palette loading example]
Additions:
- New FB-like data files, saved with ##[[KeyPgBsave Bsave]]## from FB code, containing "raw" data preceded by a 5-byte header, beginning with ##&HFE##. There is no 64 ""KiB"" limit with this format
Deletions:
- New FB-like data files, saved with ##[[KeyPgBsave Bsave]]## from FB code, containing "raw" data preceded by a 7-byte header, beginning with ##&HFE##. There is no 64 ""KiB"" limit with this format


Revision [15125]

Edited on 2011-07-26 04:37:55 by CountingPine [Add anchor for bmp_load function]
Additions:
~&//Note: When you use ##**BLoad**## to load a BMP file into an image buffer, the original dimensions of the image are not changed. If you want the image buffer to have the same dimensions as the BMP file, you have to find out the dimensions beforehand, and create an image of the right size yourself. See {{anchor name="bmp_load|the example below"}} for an example of how to do this.//
{{anchor name="bmp_load"}}
Deletions:
~&//Note: When you use ##**BLoad**## to load a BMP file into an image buffer, the original dimensions of the image are not changed. If you want the image buffer to have the same dimensions as the BMP file, you have to find out the dimensions beforehand, and create an image of the right size yourself. See below for an example of how to do this.//


Revision [15124]

Edited on 2011-07-26 04:29:35 by CountingPine [Use a const string param for bmp_load example]
Additions:
function bmp_load( byref filename as const string ) as any ptr
Deletions:
function bmp_load( byref filename as string ) as any ptr


Revision [14061]

Edited on 2008-12-23 16:58:19 by CountingPine [Add example that fetches BMP dimensions]
Additions:
~&//Note: When you use ##**BLoad**## to load a BMP file into an image buffer, the original dimensions of the image are not changed. If you want the image buffer to have the same dimensions as the BMP file, you have to find out the dimensions beforehand, and create an image of the right size yourself. See below for an example of how to do this.//
{{fbdoc item="filename" value="examples/manual/gfx/bload3.bas"}}%%(freebasic)
'' A function that creates an image buffer with the same
'' dimensions as a BMP image, and loads a file into it.
const NULL as any ptr = 0
function bmp_load( byref filename as string ) as any ptr
dim as integer filenum, bmpwidth, bmpheight
dim as any ptr img
'' open BMP file
filenum = freefile()
if open( filename for binary access read as #filenum ) <> 0 then return NULL
'' retrieve BMP dimensions
get #filenum, 19, bmpwidth
get #filenum, 23, bmpheight
close #filenum
'' create image with BMP dimensions
img = imagecreate( bmpwidth, abs(bmpheight) )
if img = NULL then return NULL
'' load BMP file into image buffer
if bload( filename, img ) <> 0 then imagedestroy( img ): return NULL
return img
end function
dim as any ptr img
screenres 640, 480, 32
img = bmp_load( "picture.bmp" )
if img = NULL then
print "bmp_load failed"
else
put (10, 10), img
imagedestroy( img )
end if
sleep%%


Revision [13999]

Edited on 2008-12-01 04:52:16 by DoS386 [pixel + buffer formats]
Additions:
- [[GfxInternalFormats Internal Graphics Formats]]
Deletions:
- [[GfxInternalFormats Internal Pixel Formats]]


Revision [13938]

Edited on 2008-11-30 07:37:28 by JeffMarshall [name case fixup]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Bload** ( [[KeyPgByref byref]] //filename// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]], [[KeyPgByval byval]] //dest// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0, [[KeyPgByval byval]] //pal// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgInteger integer]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Bload** ( [[KeyPgByref byref]] //filename// [[KeyPgAs as]] [[KeyPgConstqualifier const]] [[KeyPgString string]], [[KeyPgByval byval]] //dest// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0, [[KeyPgByval byval]] //pal// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgInteger integer]]


Revision [13930]

Edited on 2008-11-28 21:18:16 by LaananFisher [Fixed: const-correctness]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Bload** ( [[KeyPgByref byref]] //filename// [[KeyPgAs as]] [[KeyPgConstqualifier const]] [[KeyPgString string]], [[KeyPgByval byval]] //dest// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0, [[KeyPgByval byval]] //pal// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgInteger integer]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Bload** ( [[KeyPgByref byref]] //filename// [[KeyPgAs as]] [[KeyPgString string]], [[KeyPgByval byval]] //dest// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0, [[KeyPgByval byval]] //pal// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgInteger integer]]


Revision [13811]

Edited on 2008-10-24 18:17:37 by CountingPine [BLOAD converts on open into a QB-incompatible format internally]
Additions:
- Old QB-like data files, saved with ##BSAVE## from QB code, containing "raw" data preceded by a 7-byte header, beginning with ##&HFD##, up to 64 ""KiB"" in size
- BMP image files, supports a subset of valid ("Windows") .BMP files, beginning with ##"BM"##, saved from FB code with ##[[KeyPgBsave Bsave]]##, or created / saved in a compatible format using a graphics editor / converter.
QB-like data files and BMP files are converted to an FB-compatible image format when opened.
- ""FreeBASIC"" uses a different file format from QBASIC internally, which doesn't have the 64 ""KiB"" limit, and is unsupported by QBASIC.
Deletions:
- Old QB-like data files, saved with BSAVE from QB code, containing "raw" data preceded by a 7-byte header, beginning with ##&HFD##, up to 64 ""KiB"" in size
- BMP image files, supports a subset of valid ("Windows") .BMP files, beginning with ##"BM"##, saved from FB code with ##[[KeyPgBsave Bsave]]##, or created / saved in a compatible format using a graphics editor / converter.
- For non-BMP files, FB uses a different file format, not having the 64 ""KiB"" limit, and unsupported by QB


Revision [13692]

Edited on 2008-09-07 08:30:02 by JeffMarshall [name case fixup]
Additions:
- ##[[KeyPgImageDestroy ImageDestroy]]##
Deletions:
- ##[[KeyPgImagedestroy ImageDestroy]]##


Revision [13667]

Edited on 2008-09-01 12:09:54 by CountingPine [name case fixup]
Additions:
##**Bload**## can be used to load image data or any other data from a file created with ##[[KeyPgBsave Bsave]]##, and store that data in an array or paste it to the screen. If ##//dest//## is absent or null (##0##), the image data is pasted to the current graphics screen work page. Otherwise it is loaded as image data to the address given by ##//dest//##.
- Old QB-like data files, saved with BSAVE from QB code, containing "raw" data preceded by a 7-byte header, beginning with ##&HFD##, up to 64 ""KiB"" in size
- New FB-like data files, saved with ##[[KeyPgBsave Bsave]]## from FB code, containing "raw" data preceded by a 7-byte header, beginning with ##&HFE##. There is no 64 ""KiB"" limit with this format
- BMP image files, supports a subset of valid ("Windows") .BMP files, beginning with ##"BM"##, saved from FB code with ##[[KeyPgBsave Bsave]]##, or created / saved in a compatible format using a graphics editor / converter.
When loading a BMP file using ##**Bload**##, the images must be true-color (15-, 16-, 24- or 32-bits per pixel) or palettized/indexed (8-bit or lower). The image data will be converted to the proper pixel format for the current color depth, except that true-color can't be reduced to a palettized image. ##**Bload**## doesn't support BMP files using RLE compression or other image file types (PNG, JPG, GIF, ...). ##**Bload**## will load alpha channel information, if available, from 32-bit BMP files with ##BITMAPV4HEADER## or ##BITMAPV5HEADER## file headers.
- The Bitmap uses an unsupported BMP file compression type (##BI_RLE4##, ##BI_RLE8##)
'Load a 48x48 bitmap into an image
screenres 320, 200, 32
- For non-BMP files, FB uses a different file format, not having the 64 ""KiB"" limit, and unsupported by QB
- ##[[KeyPgImagecreate ImageCreate]]##
- ##[[KeyPgImagedestroy ImageDestroy]]##
Deletions:
##**Bload**## can be used to load image data or any other data from a file created with ##[[KeyPgBsave Bsave]]##, and store that data in an array or paste it to the screen. If ##//dest//## is not null (##0##), the image data is copied to memory starting at the address specified. Otherwise, it is pasted to the current graphics screen work page.
- Old QB-like data files, saved with BSAVE from QB code, containing "raw" data preceded by a 7-byte header, beginning with 0xFD, up to 64 KiB in size
- New FB-like data files, saved with BSAVE from FB code, containing "raw" data preceded by a 7-byte header, beginning with 0xFE, no 64 KiB limit anymore
- BMP image files, supports a subset of valid ("Windows") .BMP files, beginning with "BM", saved from FB code with BSAVE, or created / saved in a compatible format using a graphics editor / converter.
When loading a BMP file using ##**Bload**##, the images must be true-color (15-, 16-, 24- or 32-bits per pixel) or palettized/indexed (8-bit or lower). The image data will be converted to the proper pixel format for the current color depth, except true-color won't get reduced to a palettized image. ##**Bload**## doesn't support BMP files using RLE compression or other image file types (PNG, JPG, GIF, ...). ##**Bload**## will load alpha channel information, if available, from 32-bit BMP files with ##BITMAPV4HEADER## or ##BITMAPV5HEADER## file headers.
- The Bitmap uses an unsupported BMP file compression type (BI_RLE4, BI_RLE8)
'Load a 48x48 bitmap into an array
- For non-BMP files, FB uses a different file format, not having the 64 KiB limit, and unsupported by QB


Revision [13642]

Edited on 2008-08-02 11:15:37 by DrV [name case fixup]
Additions:
When loading a BMP file using ##**Bload**##, the images must be true-color (15-, 16-, 24- or 32-bits per pixel) or palettized/indexed (8-bit or lower). The image data will be converted to the proper pixel format for the current color depth, except true-color won't get reduced to a palettized image. ##**Bload**## doesn't support BMP files using RLE compression or other image file types (PNG, JPG, GIF, ...). ##**Bload**## will load alpha channel information, if available, from 32-bit BMP files with ##BITMAPV4HEADER## or ##BITMAPV5HEADER## file headers.
Deletions:
When loading a BMP file using ##**Bload**##, the images must be true-color (15-, 16-, 24- or 32-bits per pixel) or palettized/indexed (8-bit or lower). The image data will be converted to the proper pixel format for the current color depth, except true-color won't get reduced to a palettized image. ##**Bload**## doesn't support BMP files using RLE compression or other image file types (PNG, JPG, GIF, ...). ##**Bload**## will load alpha channel information, if available, from 32-bit BMP files with BITMAPV4HEADER or BITMAPV5HEADER file headers.


Revision [13641]

Edited on 2008-08-02 11:15:09 by DrV [name case fixup]
Additions:
- [[GfxInternalFormats Internal Pixel Formats]]
Deletions:
- ##[[GfxInternalFormats Internal Pixel Formats]]##


Revision [13640]

Edited on 2008-08-02 11:12:18 by DrV [BLOAD now supports 15/16/32 bpp, etc...]
Additions:
When using one of the 2 "non-BMP" file formats to save images, the image files must have been created with ##[[KeyPgBsave Bsave]]## in the same graphics screen mode as it is being loaded into. When using the BMP file format, this restriction doesn't apply.
When loading a BMP file using ##**Bload**##, the images must be true-color (15-, 16-, 24- or 32-bits per pixel) or palettized/indexed (8-bit or lower). The image data will be converted to the proper pixel format for the current color depth, except true-color won't get reduced to a palettized image. ##**Bload**## doesn't support BMP files using RLE compression or other image file types (PNG, JPG, GIF, ...). ##**Bload**## will load alpha channel information, if available, from 32-bit BMP files with BITMAPV4HEADER or BITMAPV5HEADER file headers.
- The Bitmap uses an unsupported BMP file compression type (BI_RLE4, BI_RLE8)
- The Bitmap is true-color (16, 24, or 32 bits per pixel) and the current graphics screen uses a palette (8 bits per pixel or lower).
Deletions:
When using one of the 2 "non-BMP" file formats to save images (nonrecommended), the image files must have been created with ##[[KeyPgBsave Bsave]]## in the same graphics screen mode as it is being loaded into. When using the BMP file format, this restriction doesn't apply.
When loading a BMP using ##**Bload**##, the images must be true-color (24- or 32- bits per pixel) or palettized/indexed (8-bit or lower in resolution). The image data will be converted to the proper pixel format for the current color depth, except true-color won't get reduced to a palettized image. ##**Bload**## doesn't support 15 or 16 bpp BMP's (rare), BMP's using the optional RLE compression (also rare), or other image file types (PNG, JPG, GIF, ...).
- The Bitmap is high-color (15 or 16 bits per pixel).
- The Bitmap is true-color (24 or 32 bits per pixel) and the current graphics screen uses a palette (8 bits per pixel or lower).


Revision [12613]

The oldest known version of this page was created on 2008-02-27 12:10:01 by MaDdogg6 [BLOAD now supports 15/16/32 bpp, etc...]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode