Revision history for KeyPgImageInfo


Revision [21535]

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

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

Edited on 2016-03-13 03:04:16 by fxm [Formatting]

No Differences

Revision [20268]

Edited on 2016-02-10 16:01:18 by DkLwikki [Update link format]
Additions:
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Imageinfo** ( [[KeyPgByval|byval]] //image// [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]], [[KeyPgByref|byref]] //width// [[KeyPgAs|as]] [[KeyPgInteger|integer]] = 0, [[KeyPgByref|byref]] //height// [[KeyPgAs|as]] [[KeyPgInteger|integer]] = 0, [[KeyPgByref|byref]] //bypp// [[KeyPgAs|as]] [[KeyPgInteger|integer]] = 0, [[KeyPgByref|byref]] //pitch// [[KeyPgAs|as]] [[KeyPgInteger|integer]] = 0, [[KeyPgByref|byref]] //pixdata// [[KeyPgAs|as]] [[KeyPgAny|any]] [[KeyPgPtr|ptr]] = 0, [[KeyPgByref|byref]] //size// [[KeyPgAs|as]] [[KeyPgInteger|integer]] = 0 ) [[KeyPgAs|as]] [[KeyPgLong|long]]
if x < 0 or x >= w then return 0
if y < 0 or y >= h then return 0
return pixdata + y * pitch + x * bypp
return 0
for x as integer = y - 5 to y + 5 step 5
'' find the pointer to pixel at x,y position
'' note: this is inefficient to do for every pixel!
pp = pixelptr(ip, x, y)
'' if success, plot a value at the pixel
if (pp <> 0) then *pp = 15
next x
- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Imageinfo""**##.
- ##[[KeyPgImagecreate|ImageCreate]]##
- ##[[KeyPgImageDestroy|ImageDestroy]]##
- ##[[KeyPgImageConvertRow|ImageConvertRow]]##
- ##[[KeyPgGetgraphics|Get (Graphics)]]##
- ##[[KeyPgPutgraphics|Put (Graphics)]]##
- [[GfxInternalFormats|Internal pixel formats]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Imageinfo** ( [[KeyPgByval byval]] //image// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]], [[KeyPgByref byref]] //width// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //height// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //bypp// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //pitch// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //pixdata// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0, [[KeyPgByref byref]] //size// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0 ) [[KeyPgAs as]] [[KeyPgLong long]]
if x < 0 or x >= w then return 0
if y < 0 or y >= h then return 0
return pixdata + y * pitch + x * bypp
return 0
for x as integer = y - 5 to y + 5 step 5
'' find the pointer to pixel at x,y position
'' note: this is inefficient to do for every pixel!
pp = pixelptr(ip, x, y)
'' if success, plot a value at the pixel
if (pp <> 0) then *pp = 15
next x
- Not available in the //[[CompilerOptlang -lang qb]]// dialect unless referenced with the alias ##**""__Imageinfo""**##.
- ##[[KeyPgImagecreate ImageCreate]]##
- ##[[KeyPgImageDestroy ImageDestroy]]##
- ##[[KeyPgImageConvertRow ImageConvertRow]]##
- ##[[KeyPgGetgraphics Get (Graphics)]]##
- ##[[KeyPgPutgraphics Put (Graphics)]]##
- [[GfxInternalFormats Internal pixel formats]]


Revision [17744]

Edited on 2015-08-06 03:56:10 by FxMwikki [Changed 'ULong Ptr' instead of 'UInteger Ptr' in 2nd example for 64-bit compatibility]
Additions:
dim row as ulong ptr = pixels + y * pitch
Deletions:
dim row as uinteger ptr = pixels + y * pitch


Revision [17508]

Edited on 2015-04-01 12:02:38 by DkLwikki [integer => long (result only)]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Imageinfo** ( [[KeyPgByval byval]] //image// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]], [[KeyPgByref byref]] //width// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //height// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //bypp// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //pitch// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //pixdata// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0, [[KeyPgByref byref]] //size// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0 ) [[KeyPgAs as]] [[KeyPgLong long]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Imageinfo** ( [[KeyPgByval byval]] //image// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]], [[KeyPgByref byref]] //width// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //height// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //bypp// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //pitch// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //pixdata// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0, [[KeyPgByref byref]] //size// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0 ) [[KeyPgAs as]] [[KeyPgInteger integer]]


Revision [15526]

Edited on 2011-11-25 11:00:14 by CountingPine [Add image for pixelptr() example]
Additions:
{{image class="center" title="Output image for pixelptr() example" url="/images/pixelptr.png"}}


Revision [15525]

Edited on 2011-11-25 09:40:56 by CountingPine [Add example to show how to get pointers to individual pixels]
Additions:
{{fbdoc item="filename" value="examples/manual/gfx/pixelptr.bas"}}%%(freebasic)
'' pixelptr(): use imageinfo() to find the pointer to a pixel in the image
'' returns null on error or x,y out of bounds
function pixelptr(byval img as any ptr, byval x as integer, byval y as integer) as any ptr
dim as integer w, h, bypp, pitch
dim as any ptr pixdata
dim as integer success
success = (imageinfo(img, w, h, bypp, pitch, pixdata) = 0)
if success then
if x < 0 or x >= w then return 0
if y < 0 or y >= h then return 0
return pixdata + y * pitch + x * bypp
else
return 0
end if
end function
'' usage example:
'' 320*200 graphics screen, 8 bits per pixel
screenres 320, 200, 8
dim as any ptr ip '' image pointer
dim as byte ptr pp '' pixel pointer (use byte for 8 bits per pixel)
ip = imagecreate(32, 32) '' create an image (32*32, 8 bits per pixel)
if ip <> 0 then
'' draw a pattern on the image
for y as integer = 0 to 31
for x as integer = y - 5 to y + 5 step 5
'' find the pointer to pixel at x,y position
'' note: this is inefficient to do for every pixel!
pp = pixelptr(ip, x, y)
'' if success, plot a value at the pixel
if (pp <> 0) then *pp = 15
next x
next y
'' put the image and draw a border around it
put (10, 10), ip, pset
line (9, 9)-step(33, 33), 4, b
'' destroy the image to reclaim memory
imagedestroy ip
else
print "Error creating image!"


Revision [14106]

Edited on 2009-01-18 14:03:27 by CountingPine [Add example to show how to get pointers to individual pixels]
Additions:
Stores the pitch of the image - i.e. the size of each scanline (row), in bytes. Note that this may be more than just ##//width// * //bypp//##, because the scanlines may be padded to allow them to be aligned better in memory.
Deletions:
Stores the pitch of the image - i.e. the size of each scanline (row), in bytes. Note that this may be more than just ##//width// * //bypp//##, because it may be padded to allow the scanlines to be aligned better in memory.


Revision [14105]

Edited on 2009-01-18 14:01:46 by CountingPine [Some edits/clarifications; change the example code so it can compile in lang fblite]
Additions:
Stores the width of the image, in pixels.
Stores the height of the image, in pixels.
Stores the bytes per pixel of the image - i.e. the size of a single pixel, in bytes.
Stores the pitch of the image - i.e. the size of each scanline (row), in bytes. Note that this may be more than just ##//width// * //bypp//##, because it may be padded to allow the scanlines to be aligned better in memory.
Stores the address of the start of the first scanline of the image.
Stores the size of the image in memory, in bytes.
It can also provide the size of the image in memory, which is useful for allocating memory to copy the existing image, or to write the image to a file.
dim image as any ptr = imagecreate( 64, 64 )
row[x] = rgb(x * 4, y * 4, (x xor y) * 4)
- New to ""FreeBASIC""
Deletions:
Stores the width, in pixels, of the image.
Stores the height, in pixels, of the image.
Stores the size, in bytes, of a single pixel in the image.
Stores the size, in bytes, of each scanline, or row, of the image.
Stores the address of the first scanline, or row, of the image.
Stores the size, in bytes, of the image in memory.
It also provides the size of the image in memory, which is useful for allocating memory to copy the existing image or to read from or write to a file or device.
var image = imagecreate( 64, 64 )
row[x] = rgb(x * 4, y * 4, (x xor y) * 4)
- New to FreeBASIC


Revision [13995]

Edited on 2008-11-30 12:19:17 by LaananFisher [Updated: reworded]
Additions:
Retrieves information about an image
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Imageinfo** ( [[KeyPgByval byval]] //image// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]], [[KeyPgByref byref]] //width// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //height// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //bypp// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //pitch// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //pixdata// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0, [[KeyPgByref byref]] //size// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0 ) [[KeyPgAs as]] [[KeyPgInteger integer]]
//result// = **Imageinfo**( //image// [, [//width//] [, [//height//] [, [//bypp//] [, [//pitch//] [, [//pixdata//] [, //size//]]]]]] )
##//image//##
The address of the image.
Stores the width, in pixels, of the image.
Stores the height, in pixels, of the image.
Stores the size, in bytes, of a single pixel in the image.
Stores the size, in bytes, of each scanline, or row, of the image.
Stores the address of the first scanline, or row, of the image.
##//size//##
Stores the size, in bytes, of the image in memory.
If ##//image//## doesn't point to a valid image, one (##1##) is returned. Otherwise, ##//width//##, ##//height//##, ##//bypp//##, ##//pitch//##, ##//pixdata//## and ##//size//## are assigned appropriate values, and zero (##0##) is returned.
##**""ImageInfo""**## provides various information about an image, such as its dimensions and color depth, but also provides you with the information you need to directly access all the pixel data in the pixel buffer.
It also provides the size of the image in memory, which is useful for allocating memory to copy the existing image or to read from or write to a file or device.
'' Create 32-bit graphics screen and image.
screenres 320, 200, 32
var image = imagecreate( 64, 64 )
dim pitch as integer
dim pixels as any ptr
'' Get enough information to iterate through the pixel data.
if 0 <> imageinfo( image, ,,, pitch, pixels ) then
print "unable to retrieve image information."
sleep
end
end if
'' Draw a pattern on the image by directly manipulating pixel memory.
for y as integer = 0 to 63
dim row as uinteger ptr = pixels + y * pitch
for x as integer = 0 to 63
row[x] = rgb(x * 4, y * 4, (x xor y) * 4)
next x
next y
'' Draw the image onto the screen.
put (10, 10), image
imagedestroy( image )
sleep
Deletions:
Retrieves information about a ""FreeBASIC"" image buffer
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Imageinfo** ( [[KeyPgByval byval]] //img// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]], [[KeyPgByref byref]] //width// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //height// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //bypp// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //pitch// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0, [[KeyPgByref byref]] //pixdata// [[KeyPgAs as]] [[KeyPgAny any]] [[KeyPgPtr ptr]] = 0, [[KeyPgByref byref]] //imgsize// [[KeyPgAs as]] [[KeyPgInteger integer]] = 0 ) [[KeyPgAs as]] [[KeyPgInteger integer]]
//result// = **Imageinfo** ( //img// [, [//width//] [, [//height//] [, [//bypp//] [, [//pitch//] [, [//pixdata//] [, [//imgsize//]]]]]]] )
##//img//##
pointer to start of image data
width of image
height of image
bytes per pixel
bytes needed per scanline
pointer to start of pixel data
##//imgsize//##
total memory used by image
##0## on success, or ##1## if an invalid header is detected.
##**Imageinfo**## provides you with useful information about an image, such as its dimensions and color depth, but also provides you with the information you need to directly access all the pixel data in the pixel buffer.
It also provides the size of image buffer in memory, which is useful for when you want to copy the buffer or store it in a file.
Dim img As Any Ptr, pixdata As Any Ptr, pitch As Integer
'' Create 32-bit screen and image buffer
ScreenRes 320, 200, 32
img = ImageCreate(64, 64)
'' get pitch and pixel data pointer of image
imageinfo img, ,,, pitch, pixdata
'' draw pattern directly into the image memory
For y As Integer = 0 To 63
Dim As UInteger Ptr p = pixdata + y * pitch

For x As Integer = 0 To 63
p[x] = RGB(x * 4, y * 4, (x Xor y) * 4)
Next x
Next y
'' Put the image to screen
Put (10, 10), img
'' Free the image memory
ImageDestroy img
'' Wait for a keypress before closing
Sleep


Revision [13703]

Edited on 2008-09-07 10:55:38 by JeffMarshall [+img parameter in usage and param sections]
Additions:
//result// = **Imageinfo** ( //img// [, [//width//] [, [//height//] [, [//bypp//] [, [//pitch//] [, [//pixdata//] [, [//imgsize//]]]]]]] )
##//img//##
pointer to start of image data
Deletions:
& This feature is only available in fbc version 0.20.0 and later.
//result// = **Imageinfo** ( [//width//] [, [//height//] [, [//bypp//] [, [//pitch//] [, [//pixdata//] [, [//imgsize//]]]]]] )


Revision [13450]

The oldest known version of this page was created on 2008-06-24 19:50:00 by CountingPine [+img parameter in usage and param sections]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode