Page: FBgfx Image and Font Buffers
Page: FBgfx Image and Font Buffers
First, there is a dead line on (A) TutFBgfxImgAndFontBuf. Remove the link?
Second, I was looking for the fb.image structure, which I could only find on the 'tutorial' wiki page above.
If it is part of freebasic since verion 0.17, it deserves a place on a 'real' reference page I think.
There are these related pages (that I could find):
(B) Internal graphics formats which explains old and new buffer format, but not the data type.
(C) GET/PUT image header example which is quite confusing and obsolete I think.
(D) IMAGEINFO which offers the same functionality in a different way, but does not really mention fb.image as an alternative. It does link to (B).
Documentation seems a bit messy with some history.
Remove (C), expand (B) with details on the fb.image structure?
Is it better to use "ImageInfo" than using the fb.image structure?
The structure is more convenient I think, but involves 'scary' pointers.
Second, I was looking for the fb.image structure, which I could only find on the 'tutorial' wiki page above.
If it is part of freebasic since verion 0.17, it deserves a place on a 'real' reference page I think.
There are these related pages (that I could find):
(B) Internal graphics formats which explains old and new buffer format, but not the data type.
(C) GET/PUT image header example which is quite confusing and obsolete I think.
(D) IMAGEINFO which offers the same functionality in a different way, but does not really mention fb.image as an alternative. It does link to (B).
Documentation seems a bit messy with some history.
Remove (C), expand (B) with details on the fb.image structure?
Is it better to use "ImageInfo" than using the fb.image structure?
The structure is more convenient I think, but involves 'scary' pointers.
Re: Page: FBgfx Image and Font Buffers
At the ImageInfo documentation page, by presenting 'ImageInfo()' as an alternative to easily access the main characteristics of an image, rather than directly accessing the internal FB.IMAGE structure through a typed pointer to member data, we could therefore show this structure rather as information.
Re: Page: FBgfx Image and Font Buffers
An fb.image structure is in fbgfx.bi, or is it now an internal structure in the latest build?
Re: Page: FBgfx Image and Font Buffers
To my knowledge, a single fb.image structure is defined in fbgfx.bi, also used by the internal code.
Re: Page: FBgfx Image and Font Buffers
Is there not an error in fbgfx.bi with IMAGE?
Because of type as ulong in the union, you can no longer use the optional property.
You have to change to
_type as ulong or something similar.
Code: Select all
'' Image buffer header, old style
''
type _OLD_HEADER field = 1
bpp : 3 as ushort
width : 13 as ushort
height as ushort
end type
'' Image buffer header, new style (incorporates old header)
''
type IMAGE field = 1
union
old as _OLD_HEADER
_type as ulong ''<<----- type as ulong causes error
end union
bpp as long
width as ulong
height as ulong
pitch as ulong
_reserved(1 to 12) as ubyte
' '' properties
declare property pixels() as ubyte ptr
end type
'' This is a trick to obtain a pointer to the pixels data area
''
property IMAGE.pixels() as ubyte ptr
return cast(ubyte ptr, @this) + sizeof(IMAGE)
end property
screen 19
dim as image ptr i
i=imagecreate(900,300)
print i->_type
print i->pixels
dim as ubyte ptr p
imageinfo i,,,,,p
print p
sleep
You have to change to
_type as ulong or something similar.
Re: Page: FBgfx Image and Font Buffers
Yes, if we un-comment the 'pixels()' property, 'type' can no longer be used as a member name.
But I'm not sure if the member name 'type' is used as is by the internal code, but think it is, otherwise I don't see the point in commenting out this property declaration/definition.
Otherwise, I would have simplify the definition of the 'pixels()' property as:in order to additionally be able to use it as an initializer/assignment of any user pointer.
But I'm not sure if the member name 'type' is used as is by the internal code, but think it is, otherwise I don't see the point in commenting out this property declaration/definition.
Otherwise, I would have simplify the definition of the 'pixels()' property as:
Code: Select all
property IMAGE.pixels() as any ptr
return @This + 1
end property
Re: Page: FBgfx Image and Font Buffers
Neither confused nor obsolete.badidea wrote:(C) GET/PUT image header example which is quite confusing and obsolete I think.
This simple example shows how access the image information directly in the image header structure ('PUT_HEADER', being an alias of the 'IMAGE' Type) and not through the 'ImageInfo()' keyword.
Re: Page: FBgfx Image and Font Buffers
You can bring the property out into an extension of fb.image (in fbgfx.bi).
But it is of no benefit, but it avoids a compile error.
But it is of no benefit, but it avoids a compile error.
Code: Select all
#include "fbgfx.bi"
type _image extends fb.image
declare property pixels() as ubyte ptr
end type
property _IMAGE.pixels() as ubyte ptr
return cast(any ptr, @this) + sizeof(fb.IMAGE)
end property
screen 19 ,32
dim as _image ptr i=imagecreate(401,342)
print i->width,i->height,i->bpp
print i->pixels
print
dim as any ptr p
dim as integer w,h,bpp
imageinfo i,w,h,bpp,,p
print w,h,bpp
print p
sleep
imagedestroy(i)
Re: Page: FBgfx Image and Font Buffers
Ok, maybe not obsolete. But why 2 names for the same thing?fxm wrote:Neither confused nor obsolete.badidea wrote:(C) GET/PUT image header example which is quite confusing and obsolete I think.
This simple example shows how access the image information directly in the image header structure ('PUT_HEADER', being an alias of the 'IMAGE' Type) and not through the 'ImageInfo()' keyword.
For documentation I would chose the most clear name which is IMAGE for me.
Confusing, because there are (at least) 3 ways to access to same information (imageInfo, fb.image, fb.put_header).
At least a remark on fb.image should be on this page I think.
You suggest add this to the ImageInfo page?fxm wrote:At the ImageInfo documentation page, by presenting 'ImageInfo()' as an alternative to easily access the main characteristics of an image, rather than directly accessing the internal FB.IMAGE structure through a typed pointer to member data, we could therefore show this structure rather as information.
Re: Page: FBgfx Image and Font Buffers
Yes.badidea wrote:You suggest add this to the ImageInfo page?fxm wrote:At the ImageInfo documentation page, by presenting 'ImageInfo()' as an alternative to easily access the main characteristics of an image, rather than directly accessing the internal FB.IMAGE structure through a typed pointer to member data, we could therefore show this structure rather as information.
Re: Page: FBgfx Image and Font Buffers
Why of no benefit? I think it is quite convenient that you can access the pixel pointer without declaring a variable first and then passing as an argument to a function call.dodicat wrote:You can bring the property out into an extension of fb.image (in fbgfx.bi).
But it is of no benefit, but it avoids a compile error.
...
Code: Select all
print i->pixels
Code: Select all
dim as any ptr p
imageinfo i,,,,,p
print p
Re: Page: FBgfx Image and Font Buffers
Done, but I left out 'we could therefore show this structure rather as information'. Not sure what you mean with that and it its adds anything. But if is does, I am quite sure you know how to edit the page.fxm wrote:Yes.badidea wrote:You suggest add this to the ImageInfo page?fxm wrote:At the ImageInfo documentation page, by presenting 'ImageInfo()' as an alternative to easily access the main characteristics of an image, rather than directly accessing the internal FB.IMAGE structure through a typed pointer to member data, we could therefore show this structure rather as information.
I must say that like MediaWiki more than WikkaWiki. And WikkaWiki seems end of life, see 'So long, and thanks for all the fish' note on: http://wikkawiki.org/HomePage
Re: Page: FBgfx Image and Font Buffers
Yes indeed, this is not like for the EVENT and FBARRAY structures for example, where it is mandatory to access the names of the member data to obtain the desired information.badidea wrote:Done, but I left out 'we could therefore show this structure rather as information'.
In the case of the IMAGE structure, a specific user interface ('ImageInfo ()') exists.
Re: Page: FBgfx Image and Font Buffers
imageinfo still remains as one of the awkward points regarding 32bits vs 64 bits.
You can use long or integer in 32 bits, but only integer in 64 bits (including gas64) for retrieved information.
There have been a number of posts regarding the usage of long/integer in 32/64 bits.
badidea.
I use fbide, but didn't indent on that occasion.
You can use long or integer in 32 bits, but only integer in 64 bits (including gas64) for retrieved information.
There have been a number of posts regarding the usage of long/integer in 32/64 bits.
badidea.
I use fbide, but didn't indent on that occasion.
Re: Page: FBgfx Image and Font Buffers
But the two image chunk header structures (the old or the new), extracted from fbgfx.bi, can be added in the 'Internal graphics formats' documentation page, to highlighter the description text of each header structure and its size (4 or 32 bytes).fxm wrote:Yes indeed, this is not like for the EVENT and FBARRAY structures for example, where it is mandatory to access the names of the member data to obtain the desired information.badidea wrote:Done, but I left out 'we could therefore show this structure rather as information'.
In the case of the IMAGE structure, a specific user interface ('ImageInfo ()') exists.
[edit]
Done.