Revision history for KeyPgImagecreate


Revision [21567]

Last edited on 2016-08-15 13:45:22 by fxm [ImageCreate() doesn't return an error code of course, because it returns the image pointer or NULL.]
Deletions:
The error code returned by ##**""ImageCreate""**## can be checked using ##[[KeyPgErr|Err]]## in the next line. The function version of ##**""ImageCreate""**## returns directly the error code as a 32 bit ##[[KeyPgLong|Long]]##.


Revision [21534]

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

Edited on 2016-04-06 03:28:29 by fxm [The error code returned can also be checked using Err()]
Additions:
The error code returned by ##**""ImageCreate""**## 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 [20942]

Edited on 2016-03-13 03:02:36 by fxm [Formatting]
Additions:





Revision [20266]

Edited on 2016-02-10 16:01:14 by DkLwikki [Update link format]
Additions:
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **""ImageCreate""** ( [[KeyPgByval|byval]] //width// [[KeyPgAs|as]] [[KeyPgLong|long]], [[KeyPgByval|byval]] //height// [[KeyPgAs|as]] [[KeyPgLong|long]], [[KeyPgByval|byval]] //color// [[KeyPgAs|as]] [[KeyPgUlong|ulong]] = **transparent_color** ) [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]]
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **""ImageCreate""** ( [[KeyPgByval|byval]] //width// [[KeyPgAs|as]] [[KeyPgLong|long]], [[KeyPgByval|byval]] //height// [[KeyPgAs|as]] [[KeyPgLong|long]], [[KeyPgByval|byval]] //color// [[KeyPgAs|as]] [[KeyPgUlong|ulong]] = **transparent_color**, [[KeyPgByval|byval]] //depth// [[KeyPgAs|as]] [[KeyPgLong|long]] ) [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]]
Consequently, in case of ##[[KeyPgShared|Shared]]## variable declaration, ##**""ImageCreate""**## cannot be used as integrated initializer, even inside an ##[[KeyPgType|UDT]]## (in member field or constructor), because the initialization value (of shared variable) is set at the start of the program before any user code is run. The image allocation call must be in a separated executable instruction, and after the graphic mode initialization.
Both procedures attempt to allocate memory for an image of the specified ##//width//## and ##//height//##. If not successful, NULL (##0##) is returned. Otherwise, an image of that size is created and initialized by filling the entire area of pixels with the value ##//color//##. If not specified, ##//color//## assumes the value of the transparent color for the current graphics screen, which can be found by calling ##[[KeyPgScreencontrol|ScreenControl]]##. In any case, the address of the image is returned, which is then controlled by the user, and must be destroyed using ##[[KeyPgImageDestroy|ImageDestroy]]##.
The first procedure creates an image with a color depth matching that of the current graphics screen, which can be found by calling ##[[KeyPgScreencontrol|ScreenControl]]##. The second procedure creates an image with a color depth of ##//depth//##, in bits per pixel. For both procedures, the resulting image can be used in drawing procedures while in any screen mode -- and across mode changes -- as long as the color depth of the image matches that of the graphics screen.
##**""ImageCreate""**## is the recommended way to allocate memory for new images. The memory layout -- size, structure, etc. -- while documented, may change from version to version, making manual calculation of the sizes involved error-prone. However, ##[[KeyPgImageInfo|ImageInfo]]## can be used to retrieve, among other things, the size, in bytes, of an existing image, allowing memory to be manually allocated for a copy of an image, or to be read from or written to a file or device.
##[[KeyPgGetgraphics|Get (Graphics)]]## can be used to initialize an image using pre-allocated memory.
- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Imagecreate""**##.
- ##[[KeyPgImageDestroy|ImageDestroy]]##
- ##[[KeyPgImageInfo|ImageInfo]]##
- ##[[KeyPgGetgraphics|Get (Graphics)]]##
- [[GfxInternalFormats|Internal pixel formats]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **""ImageCreate""** ( [[KeyPgByval byval]] //width// [[KeyPgAs as]] [[KeyPgLong long]], [[KeyPgByval byval]] //height// [[KeyPgAs as]] [[KeyPgLong long]], [[KeyPgByval byval]] //color// [[KeyPgAs as]] [[KeyPgUlong ulong]] = **transparent_color** ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **""ImageCreate""** ( [[KeyPgByval byval]] //width// [[KeyPgAs as]] [[KeyPgLong long]], [[KeyPgByval byval]] //height// [[KeyPgAs as]] [[KeyPgLong long]], [[KeyPgByval byval]] //color// [[KeyPgAs as]] [[KeyPgUlong ulong]] = **transparent_color**, [[KeyPgByval byval]] //depth// [[KeyPgAs as]] [[KeyPgLong long]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
Consequently, in case of ##[[KeyPgShared Shared]]## variable declaration, ##**""ImageCreate""**## cannot be used as integrated initializer, even inside an ##[[KeyPgType UDT]]## (in member field or constructor), because the initialization value (of shared variable) is set at the start of the program before any user code is run. The image allocation call must be in a separated executable instruction, and after the graphic mode initialization.
Both procedures attempt to allocate memory for an image of the specified ##//width//## and ##//height//##. If not successful, NULL (##0##) is returned. Otherwise, an image of that size is created and initialized by filling the entire area of pixels with the value ##//color//##. If not specified, ##//color//## assumes the value of the transparent color for the current graphics screen, which can be found by calling ##[[KeyPgScreencontrol ScreenControl]]##. In any case, the address of the image is returned, which is then controlled by the user, and must be destroyed using ##[[KeyPgImageDestroy ImageDestroy]]##.
The first procedure creates an image with a color depth matching that of the current graphics screen, which can be found by calling ##[[KeyPgScreencontrol ScreenControl]]##. The second procedure creates an image with a color depth of ##//depth//##, in bits per pixel. For both procedures, the resulting image can be used in drawing procedures while in any screen mode -- and across mode changes -- as long as the color depth of the image matches that of the graphics screen.
##**""ImageCreate""**## is the recommended way to allocate memory for new images. The memory layout -- size, structure, etc. -- while documented, may change from version to version, making manual calculation of the sizes involved error-prone. However, ##[[KeyPgImageInfo ImageInfo]]## can be used to retrieve, among other things, the size, in bytes, of an existing image, allowing memory to be manually allocated for a copy of an image, or to be read from or written to a file or device.
##[[KeyPgGetgraphics Get (Graphics)]]## can be used to initialize an image using pre-allocated memory.
- Not available in the //[[CompilerOptlang -lang qb]]// dialect unless referenced with the alias ##**""__Imagecreate""**##.
- ##[[KeyPgImageDestroy ImageDestroy]]##
- ##[[KeyPgImageInfo ImageInfo]]##
- ##[[KeyPgGetgraphics Get (Graphics)]]##
- [[GfxInternalFormats Internal pixel formats]]


Revision [17671]

Edited on 2015-06-12 05:55:38 by FxMwikki [Suppressed the no-relevant keyword 'Overload' in Syntax]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **""ImageCreate""** ( [[KeyPgByval byval]] //width// [[KeyPgAs as]] [[KeyPgLong long]], [[KeyPgByval byval]] //height// [[KeyPgAs as]] [[KeyPgLong long]], [[KeyPgByval byval]] //color// [[KeyPgAs as]] [[KeyPgUlong ulong]] = **transparent_color** ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **""ImageCreate""** [[KeyPgOverload overload]] ( [[KeyPgByval byval]] //width// [[KeyPgAs as]] [[KeyPgLong long]], [[KeyPgByval byval]] //height// [[KeyPgAs as]] [[KeyPgLong long]], [[KeyPgByval byval]] //color// [[KeyPgAs as]] [[KeyPgUlong ulong]] = **transparent_color** ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]


Revision [17507]

Edited on 2015-04-01 12:02:06 by DkLwikki [integer => long]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **""ImageCreate""** [[KeyPgOverload overload]] ( [[KeyPgByval byval]] //width// [[KeyPgAs as]] [[KeyPgLong long]], [[KeyPgByval byval]] //height// [[KeyPgAs as]] [[KeyPgLong long]], [[KeyPgByval byval]] //color// [[KeyPgAs as]] [[KeyPgUlong ulong]] = **transparent_color** ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **""ImageCreate""** ( [[KeyPgByval byval]] //width// [[KeyPgAs as]] [[KeyPgLong long]], [[KeyPgByval byval]] //height// [[KeyPgAs as]] [[KeyPgLong long]], [[KeyPgByval byval]] //color// [[KeyPgAs as]] [[KeyPgUlong ulong]] = **transparent_color**, [[KeyPgByval byval]] //depth// [[KeyPgAs as]] [[KeyPgLong long]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **""ImageCreate""** [[KeyPgOverload overload]] ( [[KeyPgByval byval]] //width// [[KeyPgAs as]] [[KeyPgInteger integer]], [[KeyPgByval byval]] //height// [[KeyPgAs as]] [[KeyPgInteger integer]], [[KeyPgByval byval]] //color// [[KeyPgAs as]] [[KeyPgUinteger uinteger]] = **transparent_color** ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **""ImageCreate""** ( [[KeyPgByval byval]] //width// [[KeyPgAs as]] [[KeyPgInteger integer]], [[KeyPgByval byval]] //height// [[KeyPgAs as]] [[KeyPgInteger integer]], [[KeyPgByval byval]] //color// [[KeyPgAs as]] [[KeyPgUinteger uinteger]] = **transparent_color**, [[KeyPgByval byval]] //depth// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]


Revision [15206]

Edited on 2011-08-27 16:54:31 by FxMwikki [formatting]
Additions:
Consequently, in case of ##[[KeyPgShared Shared]]## variable declaration, ##**""ImageCreate""**## cannot be used as integrated initializer, even inside an ##[[KeyPgType UDT]]## (in member field or constructor), because the initialization value (of shared variable) is set at the start of the program before any user code is run. The image allocation call must be in a separated executable instruction, and after the graphic mode initialization.
Deletions:
Consequently, in case of **shared** variable declaration, ##**""ImageCreate""**## cannot be used as integrated initializer, even inside a **Type** (in a member field or a constructor), because this initialization value (of the shared variable) is set at the start of the program before any code is run. The image allocation call must be in a separated executable instruction, and after the graphic mode initialization.


Revision [15205]

Edited on 2011-08-27 08:47:51 by FxMwikki [ImageCreate versus graphic mode initialization and shared variable declaration]
Additions:
If the image could not be created, NULL (##0##) is returned, otherwise, the address of the image is returned. ##**""ImageCreate""**## must be called after graphic mode initialization, else it returns ##0##.
Consequently, in case of **shared** variable declaration, ##**""ImageCreate""**## cannot be used as integrated initializer, even inside a **Type** (in a member field or a constructor), because this initialization value (of the shared variable) is set at the start of the program before any code is run. The image allocation call must be in a separated executable instruction, and after the graphic mode initialization.
Deletions:
If the image could not be created, NULL (##0##) is returned. Otherwise, the address of the image is returned.


Revision [14359]

Edited on 2009-08-29 21:54:34 by CountingPine [Remove CamelCase links in "New to FreeBASIC"]
Additions:
- New to ""FreeBASIC""
Deletions:
- New to FreeBASIC


Revision [14101]

Edited on 2009-01-18 10:12:56 by JeffMarshall [name case fixup]
Additions:
Both procedures attempt to allocate memory for an image of the specified ##//width//## and ##//height//##. If not successful, NULL (##0##) is returned. Otherwise, an image of that size is created and initialized by filling the entire area of pixels with the value ##//color//##. If not specified, ##//color//## assumes the value of the transparent color for the current graphics screen, which can be found by calling ##[[KeyPgScreencontrol ScreenControl]]##. In any case, the address of the image is returned, which is then controlled by the user, and must be destroyed using ##[[KeyPgImageDestroy ImageDestroy]]##.
The first procedure creates an image with a color depth matching that of the current graphics screen, which can be found by calling ##[[KeyPgScreencontrol ScreenControl]]##. The second procedure creates an image with a color depth of ##//depth//##, in bits per pixel. For both procedures, the resulting image can be used in drawing procedures while in any screen mode -- and across mode changes -- as long as the color depth of the image matches that of the graphics screen.
Deletions:
Both procedures attempt to allocate memory for an image of the specified ##//width//## and ##//height//##. If not successful, NULL (##0##) is returned. Otherwise, an image of that size is created and initialized by filling the entire area of pixels with the value ##//color//##. If not specified, ##//color//## assumes the value of the transparent color for the current graphics screen, which can be found by calling ##[[KeyPgScreenControl ScreenControl]]##. In any case, the address of the image is returned, which is then controlled by the user, and must be destroyed using ##[[KeyPgImageDestroy ImageDestroy]]##.
The first procedure creates an image with a color depth matching that of the current graphics screen, which can be found by calling ##[[KeyPgScreenControl ScreenControl]]##. The second procedure creates an image with a color depth of ##//depth//##, in bits per pixel. For both procedures, the resulting image can be used in drawing procedures while in any screen mode -- and across mode changes -- as long as the color depth of the image matches that of the graphics screen.


Revision [13996]

Edited on 2008-11-30 12:19:20 by LaananFisher [Updated: byval/overload/reworded]
Additions:
Allocates and initializes storage for an image
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **""ImageCreate""** [[KeyPgOverload overload]] ( [[KeyPgByval byval]] //width// [[KeyPgAs as]] [[KeyPgInteger integer]], [[KeyPgByval byval]] //height// [[KeyPgAs as]] [[KeyPgInteger integer]], [[KeyPgByval byval]] //color// [[KeyPgAs as]] [[KeyPgUinteger uinteger]] = **transparent_color** ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **""ImageCreate""** ( [[KeyPgByval byval]] //width// [[KeyPgAs as]] [[KeyPgInteger integer]], [[KeyPgByval byval]] //height// [[KeyPgAs as]] [[KeyPgInteger integer]], [[KeyPgByval byval]] //color// [[KeyPgAs as]] [[KeyPgUinteger uinteger]] = **transparent_color**, [[KeyPgByval byval]] //depth// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
//result// = **""ImageCreate""**( //width//, //height// [, [ //color// ][, //depth// ]] )
The desired width, in number of pixels.
The desired height, in number of pixels.
The pixel value to fill the area of the image.
The desired color depth, in bits per pixel.
If the image could not be created, NULL (##0##) is returned. Otherwise, the address of the image is returned.
Both procedures attempt to allocate memory for an image of the specified ##//width//## and ##//height//##. If not successful, NULL (##0##) is returned. Otherwise, an image of that size is created and initialized by filling the entire area of pixels with the value ##//color//##. If not specified, ##//color//## assumes the value of the transparent color for the current graphics screen, which can be found by calling ##[[KeyPgScreenControl ScreenControl]]##. In any case, the address of the image is returned, which is then controlled by the user, and must be destroyed using ##[[KeyPgImageDestroy ImageDestroy]]##.
The first procedure creates an image with a color depth matching that of the current graphics screen, which can be found by calling ##[[KeyPgScreenControl ScreenControl]]##. The second procedure creates an image with a color depth of ##//depth//##, in bits per pixel. For both procedures, the resulting image can be used in drawing procedures while in any screen mode -- and across mode changes -- as long as the color depth of the image matches that of the graphics screen.
##**""ImageCreate""**## is the recommended way to allocate memory for new images. The memory layout -- size, structure, etc. -- while documented, may change from version to version, making manual calculation of the sizes involved error-prone. However, ##[[KeyPgImageInfo ImageInfo]]## can be used to retrieve, among other things, the size, in bytes, of an existing image, allowing memory to be manually allocated for a copy of an image, or to be read from or written to a file or device.
##[[KeyPgGetgraphics Get (Graphics)]]## can be used to initialize an image using pre-allocated memory.
'' Create a graphics screen.
screenres 320, 200, 32
'' Create a 64x64 pixel image with a darkish green background.
dim image as any ptr = imagecreate( 64, 64, rgb(0, 128, 0) )
if image = 0 then
print "Failed to create image."
sleep
end -1
end if
'' Draw a semi-transparent, red circle in the center of the image.
circle image, (32, 32), 28, rgba(255, 0, 0, 128),,, 1.0, f
'' Draw the image onto the screen using various blitting methods.
put (120, 60), image, pset
put (140, 80), image, alpha
'' Destroy the image.
imagedestroy image
sleep
Deletions:
Creates and initializes storage for an image
[[KeyPgDeclare declare]] [[KeyPgSub function]] **""ImageCreate""**( //width// [[KeyPgAs as]] [[KeyPgInteger integer]], //height// [[KeyPgAs as]] [[KeyPgInteger integer]] [, [ //color// [[KeyPgAs as]] [[KeyPgUinteger uinteger]] ] [, //depth// [[KeyPgAs as]] [[KeyPgInteger integer]] ]] ) [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]]
//buffer// = **""ImageCreate""**( //width//, //height// [, [ //color// ][, //depth// ]] )
Desired width of the image buffer to create.
Desired height of the image buffer to create.
The pixel value to fill the image buffer with upon creation.
Desired color depth of the image buffer, in bits per pixel.
The address of the image buffer, or NULL (0) if the buffer could not be created.
Allocates and initializes a memory buffer for an image. If ##//color//## is omitted, a value of 0 will be used for paletted (8-bit or less) modes, or [[KeyPgRgb RGB]](255, 0, 255) for higher color depth modes (this translates to &hF81F and &hFFFF00FF for 15/16-bit and 24/32-bit modes, respectively - see the [[GfxInternalFormats internal gfx formats]] reference for more info). These are special mask colors, which will be transparent when using ##[[KeyPgPutgraphics Put]]## with the ##[[KeyPgTransGfx Trans]]## method.

##**""ImageCreate""**## only works when a graphics mode has been set up with the ##[[KeyPgScreengraphics Screen]]## statement or ##[[KeyPgScreenres ScreenRes]]## statement. Images can be set up with different color depths from the screen color depth, using the ##//depth//## parameter. An image buffer can be passed to graphics functions across mode changes as long as the different modes use the same color depth.

Images should be deleted with ##[[KeyPgImageDestroy ImageDestroy]]## when they are no longer needed, in order to prevent memory leaks.
The ##**""ImageCreate""**## function is an alternative to using the ##[[KeyPgGetgraphics Get (Graphics)]]## statement to create a buffer, and can ease the creation of an image buffer for use 2D drawing functions. It is recommended that you always use ##**""ImageCreate""**## though, as it automatically allocates the correct size for the buffer, given its dimensions and the current color depth; the image header may vary in size in future FreeBASIC releases, so using ##[[KeyPgGetgraphics Get (Graphics)]]## with a buffer allocated on the stack may result in corrupted data, as the static buffer size may have been manually computed using a formula that is no longer valid.
Dim image_buffer As Any Ptr
Const NULL as Any Ptr = 0
'' set screen mode (this must be done before trying to create an image)
Screenres 320, 200, 32
'' allocate an image buffer with a darkish green background
image_buffer = ImageCreate(64, 64, RGB(0, 128, 0))
'' check that image creation succeeded
If image_buffer = NULL Then
Print "Image creation failed!"
Sleep
End
End If
'' draw a semi-transparent, red circle to the image buffer
Circle image_buffer, (32, 32), 28, RGBA(255, 0, 0, 128),,, 1.0, F
'' blit image buffer to screen
Put (120, 60), image_buffer, PSet
Put (140, 80), image_buffer, Alpha
Sleep
'' free image buffer memory
ImageDestroy image_buffer


Revision [13328]

The oldest known version of this page was created on 2008-05-07 13:40:49 by CountingPine [Updated: byval/overload/reworded]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode