UDRes Userlibrary (Userdefined Resources use and compile)

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

UDRes Userlibrary (Userdefined Resources use and compile)

Post by ts-soft »

This library create compiled userdefined resources without another
resource-compiler, without resource-script or temporary files.
The resourcetyp is "PBDATA". Only ID-numbers, no name for the resources.

The resources can automatically packed and unpacked with brieflz. (included
in this library)

This is a good alternate to IncludeBinary. Resources a not loaded
automatically in RAM with exe or dll, other then IncludeBinary.

Only Import the created *.res and use the resource with the functions from
this lib.

English-Help and Examples included.

Download

//edit
New downloadlink
Last edited by ts-soft on Sat May 10, 2008 5:19 pm, edited 1 time in total.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Thank you ts-soft, this is very interesting. :)

I don't know a great deal about resource files. However, I'm working on a large project in which I've created quite a large resource script containing a whole bunch of icons which I then load with LoadIcon_() and display with DrawIconEx_(). Can I still do this with UDRES? My fear is that if I use CatchImage(), this then regards the icon as a bitmap and I lose the ability to display the icon with a transparent background!

I guess I'm asking if there's a way of combining UDRES with my own resource scripts also?

Impressive work nevertheless.

Thanks again.
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

@srod
Sorry, in the moment only userdefined resources. The only possible
ResourceType is "PBDATA" (same as RC_DATA, but another name)

I have no information to load it other than as this:

Code: Select all

ResName.s = "#" + Str(ResNumber)

hFind = FindResource_(hModule, ResName.s, @"PBDATA")
If hFind
  hLoad = LoadResource_(hModule, hFind)
  hSize = SizeofResource_(hModule, hFind)
  hLock = LockResource_(hLoad)

  Mem = AllocateMemory(hSize)

  If Mem
    CopyMemory(hLock, Mem, hSize)
    FreeResource_(hLock)
    ProcedureReturn Mem
  EndIf
EndIf 
The Resource Header is a dynamic Structure, it's not so easy and the
documentation isn't good, but i will enhance it in the future :wink:
So in the moment only Catch from Mem or Save to disk, but all binarys are
no problem (Catch RTF oder LoadLibraryM and so on)

I hope there comes more features in the next releases
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I understand.

Thanks.
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

I will add extra function for icons (only numbered) and stringtable. Would this
be sufficient?
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

That would be brilliant and cover about all of my needs as far as resources go.

This is going to be one handy little library. :D
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Big problem with icon and so on.
The first off header a long is the datasize, but this is different :cry:
DataSize The size of the data that follows the header. This value does not include any file padding bytes added after the actual data.
The format of the data is different for any of the possible resource types. Data size is expressed in BYTEs (8 bit unsigned integer).
The real DataSize doesn't work, i have no information to change this value
Compiled with Porc, this value isn't the FileSize, so i don't know, what is the
DataSize for icons :?:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Sorry I can't help at the mo, it's beyond my experience.
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Update

New functions:
UDRes_GetFunction
UDRes_GetPackFunction
The same Functions as GetFunction in PB, but directly for a DLL in Resource
Is DLL not loaded, so loadet automatic in memory and unload at programend.
Example:

Code: Select all

#PB_DLL = 1

Import "PureBasic.res" : EndImport

CallFunctionFast(UDRes_GetPackFunction(#PB_DLL, "EasyRequester"), "Test")
Also added a threadsafe version as subsystem

Download in first post

regards
Thomas
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Update

New Functions:
UDRes_CatchImage
UDRes_CatchPackImage
UDRes_CatchSound
UDRes_CatchPackSound
UDRes_CatchSprite
UDRes_CatchPackSprite
Nearly the same as the catchfunctions in PB, but for UserDefinded Resources
All Catched Sounds, Sprites or Images a only ones in Memory, other than
IncludeBinary!

Download in first post

regards
Thomas
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
danraymond
User
User
Posts: 43
Joined: Wed Jun 28, 2006 6:02 am

SO how do i move from this DLL call to a res file

Post by danraymond »

How do I use UDRes to get rid of this:

Code: Select all

OpenLibrary(0,"mt19937ar.dll"); opens random generator library
CallFunction(0, "init_genrand", timeGetTime_()); seed the PRNG
*genrand31 = GetFunction(0, "genrand_int31"); get pointer to function in the dll
then later in the code I do:

Code: Select all

myrandom=mindemand+Int(CallFunctionFast(*genrand31)/#MAXLONG *(maxdemand-mindemand))
so I what changes to both codes and what do I do with UDREs to achieve it?

Thanks

Dan Raymond

[/code]
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

use this for example:

Code: Select all

init_genrand = UDRes_GetFunction(1, "init_genrand")
CallFunctionFast(init_genrand, timeGetTime_())
*genrand31 = UDRes_GetFunction(1, "genrand_int31")
(DLL has Resourcenumber 1 in the example)
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Excellent work ts-soft.

Thanks.
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

srod wrote:Excellent work ts-soft.

Thanks.
thanks :D
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Update:
Added 2 Functions

Code: Select all

UDRes_GetModuleHandle(ResNumber.l [, hModule.l]) 
UDRes_GetPackModuleHandle(ResNumber.l [, hModule.l])
The result is the ModuleHandle. With this, you can load all resources from included DLL
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Post Reply