FreeBASIC Extended Library Release 0.2.2
Pretend you have a jpeg file and you load it all into a memory block and then delete the file. Instead of loading it from a file, I'd like to pass a pointer of the jpeg in memory to a load_mem function and have it then uncompress the jpeg onto a FB.IMAGE that the function would return.
If I look at the png.bi it has what I'm talking about.
I know this won't take much to add, because I've hacked it in myself with other jpeg libraries (poorly hehe). I guess it's just a rarity to have embedded jpeg's =)
If I look at the png.bi it has what I'm talking about.
Code: Select all
''Function: load_mem
''Loads a png file that has been located in memory.
''
''Parameters:
''buffer - pointer to memory buffer holding the file.
''buffer_len - the length of the buffer.
''target - the target from target_e to load to.
''
''Returns:
''Pointer to png image in memory.
''
declare function load_mem cdecl alias "png_load_mem" _
( _
byval buffer as any ptr, _
byval buffer_len as integer, _
byval target as target_e _
) as any ptr
New Release is out. Current Version is 0.2.1, see first post for download directions.
This is a bugfix release and all users are encouraged to upgrade.
Since FBC .18.3 was released yesterday we are providing a version compiled for .18.2 and one for .18.3 for windows this time.
Bugs fixed in this release:
http://code.google.com/p/fb-extended-li ... id=6&can=1 (ambiguity with crt.bi fixed)
Qsort and Bubblesort were incorrectly sorting before, they should work fine now (test cases for them have been added.)
A couple others I can't recall off the top of my head.
New Features in this release:
added ext.gfx.font.GetTextWidth - Used to determine the width of text when using a Draw String font.
added a DrawImage method to the ext.gfx.Sprite Class, see the documentation for details.
Once again, thanks to everyone who has used the Extended Library so far. All of us on the Dev team hope you continue to enjoy the improvements we're making. I'd like to see some more feedback from you guys for what you like, what we can improve on, what you'd like to see in ext and even some code contributions.
This is a bugfix release and all users are encouraged to upgrade.
Since FBC .18.3 was released yesterday we are providing a version compiled for .18.2 and one for .18.3 for windows this time.
Bugs fixed in this release:
http://code.google.com/p/fb-extended-li ... id=6&can=1 (ambiguity with crt.bi fixed)
Qsort and Bubblesort were incorrectly sorting before, they should work fine now (test cases for them have been added.)
A couple others I can't recall off the top of my head.
New Features in this release:
added ext.gfx.font.GetTextWidth - Used to determine the width of text when using a Draw String font.
added a DrawImage method to the ext.gfx.Sprite Class, see the documentation for details.
Once again, thanks to everyone who has used the Extended Library so far. All of us on the Dev team hope you continue to enjoy the improvements we're making. I'd like to see some more feedback from you guys for what you like, what we can improve on, what you'd like to see in ext and even some code contributions.
I think I found a bug in array.bi. In line 103, shouldn't the T() be T_()?
Code: Select all
declare sub Resize ( byval newsize as SizeType, byval x as T_ = T() )
I'm going to make a few demos that show how to use some of the functions in the library. Here's the first one. :)
http://dave-stanley.dyndns.org/programs/fbext_demo1.rar
http://dave-stanley.dyndns.org/programs/fbext_demo1.rar
getTextWidth isn't working right for me.
if you add this line to the freetype.bas example you'll notice it is clearly WAY off:
it will print 75, and it is clearly much larger than 75 pixels.
if you add this line to the freetype.bas example you'll notice it is clearly WAY off:
Code: Select all
print gfx.font.getTextWidth(mylargefont, "Large Text")
When using the array container, how do you set it up? this is the closest I can figure out from looking at array.bi, but it doesn't work.
I get a different set of errors depending on whether I've got the declare or define macro first
Code: Select all
#include once "ext/ext.bi"
using ext
type t
a as integer
b as string
end type
FBEXT_DECLARE_ARRAY(t)
FBEXT_DEFINE_ARRAY(t)
var b = FBEXT_ARRAY(t)
Some issues with ext.Array have been fixed in SVN, thanks Merick for posting them. An example of how to use UDT objects in ext.Array has been added in examples/containers/array-udt.bas, shown here:
Yes, there is lots of boilerplate code at the moment. Hopefully this will be brought down and/or eliminated sometime in the near future.
Code: Select all
# include once "ext/containers/array.bi"
type UDT
' Elements of ext.Array need to support in-place construction/destruction
' via overloaded member operators NEW and DELETE. This macro declares those
' members:
FBEXT_DECLARE(Placement_NewDel, UDT)
' Elements of ext.Array need to support default construction and copy
' construction:
declare constructor (n as integer = 0)
declare constructor (byref x as UDT)
n as integer
end type
' Implement the support for in-place construction/destruction:
FBEXT_DEFINE(Placement_NewDel, UDT)
' Implement other class memebers:
constructor UDT (n as integer)
this.n = n
end constructor
constructor UDT (byref x as UDT)
this.n = x.n
end constructor
namespace ext
' Implement the in-place construction/destruction helpers of the library
' for UDT objects:
FBEXT_DEFINE(Construct, UDT)
FBEXT_DEFINE(Destroy, UDT)
' Implement algorithms use by ext.Array internally for UDT ranges:
FBEXT_DEFINE(UninitializedCopy, UDT)
FBEXT_DEFINE(UninitializedFillN, UDT)
FBEXT_DEFINE(Copy, UDT)
FBEXT_DEFINE(CopyBackward, UDT)
FBEXT_DEFINE(Fill, UDT)
' Implement ext.Array for UDT elements:
FBEXT_DEFINE(Array, UDT)
end namespace
'' :::::
using ext
var a = FBEXT_ARRAY(UDT)
a.PushBack(10)
a.PushBack(20)
a.PushBack(30)
var first = a.Begin(), last = a.End_()
do while first <> last
print (*first).n
first += 1
loop
' 10
' 20
' 30