Revision history for KeyPgBsave


Revision [23201]

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


Revision [22659]

Edited on 2019-04-15 17:06:18 by badidea [Example added: Save image buffer to bitmap file]
Additions:
Save image buffer to bitmap file:
{{fbdoc item="filename" value="examples/manual/gfx/bsave2.bas"}}%%(freebasic)
'set graphics screen 640 x 480 pixels, 32 bit colors
Const W = 640, H = 480 'width & hight
Screenres W, H, 32
'draw a smiley at screen center
Circle (W \ 2, H \ 2), 180, &h00ffff00, , , , f 'yellow circle
Circle (W \ 2 - 55, H \ 2 - 70), 35, &h00000000, , , 1.5, f 'left eye
Circle (W \ 2 + 55, H \ 2 - 60), 35, &h00000000, , , 1.5, f 'right eye
Circle (W \ 2, H \ 2 + 80), 70, &h00000000, , , 0.4, f 'mouth
'allocate memory for image buffer
Dim As Any Ptr pImageBuffer = Imagecreate(250, 250)
'copy screen section to buffer
Get (W \ 2 - 125, H \ 2 - 125)-step(250 - 1, 250 - 1), pImageBuffer
'save image buffer to file
Dim As String fileName = "Smiley.bmp"
If Bsave(fileName, pImageBuffer) = 0 Then
Print "Saved succesful: " + fileName
Else
Print "Error saving: " + fileName
End If
'free memory for image buffer
Imagedestroy(pImageBuffer)
'keep graphics screen open until key press
Sleep


Revision [22658]

Edited on 2019-04-15 16:06:11 by badidea [comment clarified]
Additions:
' Save screen as BMP
Deletions:
' Save as BMP


Revision [21529]

Edited on 2016-08-13 04:37:45 by fxm [Corrected bad referring to 'Open']
Additions:
The error code returned by ##**Bsave**## can be checked using ##[[KeyPgErr|Err]]## in the next line. The function version of ##**Bsave**## returns directly the error code as a 32 bit ##[[KeyPgLong|Long]]##.
Deletions:
The error code returned by ##**Bsave**## 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 [21321]

Edited on 2016-04-06 03:02:54 by fxm [The error code returned can also be checked using Err()]
Additions:
The error code returned by ##**Bsave**## 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 [20831]

Edited on 2016-03-12 15:13:57 by fxm [Formatting]
Additions:





Revision [20068]

Edited on 2016-02-10 15:55:04 by DkLwikki [Update link format]
Additions:
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Bsave** ( [[KeyPgByref|byref]] //filename// [[KeyPgAs|as]] [[KeyPgConstQualifier|const]] [[KeyPgString|string]], [[KeyPgByval|byval]] //source// [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]], [[KeyPgByval|byval]] //size// [[KeyPgAs|as]] [[KeyPgUlong|ulong]] = 0, [[KeyPgByval|byval]] //pal// [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]] = 0, [[KeyPgByval|byval]] //bitsperpixel// [[KeyPgAs|as]] [[KeyPgLong|long]] = 0 ) [[KeyPgAs|as]] [[KeyPgLong|long]]
optional, the address of a buffer holding 256 ##[[KeyPgPalette|Palette]]## colors, or null (##0##) for the current screen palette.
Returns zero (##0##) if successful, or a non-zero error code to indicate a failure. //[[ProPgErrorHandling|(throws a runtime error)]]//
##**Bsave**## throws one of the following [[ProPgErrorHandling|runtime errors]]:
- ""QB"" cannot use ##[[KeyPgBload|Bload]]## to load files created with ##**Bsave**## in ""FreeBASIC"", but ""FreeBASIC"" can use ##[[KeyPgBload|Bload]]## to load files created with ##**Bsave**## in ""QB""
- ##[[KeyPgBload|Bload]]##
- ##[[KeyPgPalette|Palette]]##
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Bsave** ( [[KeyPgByref byref]] //filename// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]], [[KeyPgByval byval]] //source// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]], [[KeyPgByval byval]] //size// [[KeyPgAs as]] [[KeyPgUlong ulong]] = 0, [[KeyPgByval byval]] //pal// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0, [[KeyPgByval byval]] //bitsperpixel// [[KeyPgAs as]] [[KeyPgLong long]] = 0 ) [[KeyPgAs as]] [[KeyPgLong long]]
optional, the address of a buffer holding 256 ##[[KeyPgPalette Palette]]## colors, or null (##0##) for the current screen palette.
Returns zero (##0##) if successful, or a non-zero error code to indicate a failure. //[[ProPgErrorHandling (throws a runtime error)]]//
##**Bsave**## throws one of the following [[ProPgErrorHandling runtime errors]]:
- ""QB"" cannot use ##[[KeyPgBload Bload]]## to load files created with ##**Bsave**## in ""FreeBASIC"", but ""FreeBASIC"" can use ##[[KeyPgBload Bload]]## to load files created with ##**Bsave**## in ""QB""
- ##[[KeyPgBload Bload]]##
- ##[[KeyPgPalette Palette]]##


Revision [17478]

Edited on 2015-04-01 10:55:16 by DkLwikki [integer => long]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Bsave** ( [[KeyPgByref byref]] //filename// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]], [[KeyPgByval byval]] //source// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]], [[KeyPgByval byval]] //size// [[KeyPgAs as]] [[KeyPgUlong ulong]] = 0, [[KeyPgByval byval]] //pal// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0, [[KeyPgByval byval]] //bitsperpixel// [[KeyPgAs as]] [[KeyPgLong long]] = 0 ) [[KeyPgAs as]] [[KeyPgLong long]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Bsave** ( [[KeyPgByref byref]] //filename// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]], [[KeyPgByval byval]] //source// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]], [[KeyPgByval byval]] //size// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByval byval]] //pal// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0, [[KeyPgByval byval]] //bitsperpixel// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0 ) [[KeyPgAs as]] [[KeyPgInteger integer]]


Revision [16716]

Edited on 2013-04-01 21:34:55 by CountingPine [New bitsperpixel parameter, better error codes, some clarifications]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Bsave** ( [[KeyPgByref byref]] //filename// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]], [[KeyPgByval byval]] //source// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]], [[KeyPgByval byval]] //size// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByval byval]] //pal// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0, [[KeyPgByval byval]] //bitsperpixel// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0 ) [[KeyPgAs as]] [[KeyPgInteger integer]]
//result// = **Bsave**( //filename//, //source// [,[ //size// ][,[ //pal// ][, //bitsperpixel// ]]] )
optional, the total number of bytes of data to store. This value is needed unless the output is a BMP file.
optional, the address of a buffer holding 256 ##[[KeyPgPalette Palette]]## colors, or null (##0##) for the current screen palette.
##//bitsperpixel//##
optional, a requested bit depth for the output BMP image.
##**Bsave**## outputs a __total__ of ##//size//## bytes of arbitrary data located at ##//source//## to a specified file. If ##//source//## is null (##0##), then ##**Bsave**## outputs a __maximum__ of ##//size//## bytes from the current work page's pixel buffer, which is structured in the current screen mode's internal pixel format. (This data is not compatible with the image buffer format as it has no header.) For 8-bit images, palette information is obtained from ##//pal//## if present and non-null, or if ##//pal//## omitted or null (##0##), from the current screen palette.
A BMP image file can be created if ##//filename//## has a file extension of "##"".bmp""##" (case insensitive). ##//source//## is assumed to point to a valid image buffer whose entire pixel data will be stored in the BMP file. If ##//source//## is null (##0##), the contents of the current work page will be stored instead. For 8-bit images, palette information is obtained from ##//pal//## if non-null, or if null (##0##), from the current screen palette. The ##//size//## parameter is ignored when saving BMP files.
The default bit depth for BMP files is 8-bit for 8-bit (palette) images, 24-bit for 16-bit images, and 32-bit for 32-bit images. The ##//bitsperpixel//## parameter can be used to request 24-bit output for 8-bit images, or 24-bit output for 32-bit images.
//(##1##) Illegal function call//
- ##//size//## is less than zero (##0##), or ##//size//## is zero and ##//source//## is non-null, or a problem is detected with the image buffer.
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Bsave** ( [[KeyPgByref byref]] //filename// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]], [[KeyPgByval byval]] //source// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]], [[KeyPgByval byval]] //size// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByval byval]] //pal// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgInteger integer]]
//result// = **Bsave**( //filename//, //source// [,[ //size// ][, //pal// ]] )
the total number of bytes of data to store.
the address of a buffer holding 256 ##[[KeyPgPalette Palette]]## colors, or null (##0##) to use the current screen palette.
##**Bsave**## outputs a __total__ of ##//size//## bytes of arbitrary data located at ##//source//## to a specified file. If ##//source//## is null (##0##), then ##**Bsave**## outputs a __maximum__ of ##//size//## bytes from the current work page's pixel buffer, which is structured in the current screen mode's internal pixel format. Palette information is obtained from ##//pal//## if non-null, or if null (##0##), from the current screen palette.
A BMP image file can be created if ##//filename//## has a file extension of "##"".bmp""##" (case insensitive). ##//source//## is assumed to point to a valid image buffer whose entire pixel data will be stored in the BMP file. If ##//source//## is null (##0##), the entire current work page will be stored instead. Palette information is obtained from ##//pal//## if non-null, or if null (##0##), from the current screen palette. The ##//size//## parameter is ignored when saving BMP files.
- ##//size//## is less than zero (##0##), or ##//size//## is zero and ##//source//## is non-null.


Revision [16712]

Edited on 2013-03-31 20:04:20 by CountingPine [Couple of points of detail]
Additions:
the address of a buffer holding 256 ##[[KeyPgPalette Palette]]## colors, or null (##0##) to use the current screen palette.
A BMP image file can be created if ##//filename//## has a file extension of "##"".bmp""##" (case insensitive). ##//source//## is assumed to point to a valid image buffer whose entire pixel data will be stored in the BMP file. If ##//source//## is null (##0##), the entire current work page will be stored instead. Palette information is obtained from ##//pal//## if non-null, or if null (##0##), from the current screen palette. The ##//size//## parameter is ignored when saving BMP files.
Deletions:
the address of a buffer holding palette information, or null (##0##) to use the current screen palette.
A BMP image file can be created if ##//filename//## has a file extension of """BMP""". ##//source//## is assumed to point to a valid image buffer whose entire pixel data will be stored in the BMP file. If ##//source//## is null (##0##), the entire current work page will be stored instead. Palette information is obtained from ##//pal//## if non-null, or if null (##0##), from the current screen palette. The ##//size//## parameter is ignored when saving BMP files.


Revision [13939]

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


Revision [13931]

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


Revision [12608]

The oldest known version of this page was created on 2008-02-27 02:48:58 by DoS386 [Fixed: const-correctness]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode