Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / unsigned char * to dbMemblock

Author
Message
N3wton
15
Years of Service
User Offline
Joined: 3rd Jun 2009
Location: Leeds, UK
Posted: 17th Sep 2010 02:04
Hello...

I'm trying to find the fastest way to convert an unsigned char * to a dbMemblock...

The unsigned char* contains information about an image (without a header, just the pixels in a BGRA format, though I can change it to an ARGB format which would make more sense).

At the moment I am taking the unsigned char *, inttialised with the following

Quote: "webBuffer = new unsigned char[width * height * 4];"

(where width and height are the width and height of the image.)

then saving out the information to an external temp.tga, I then reload the image using dbLoadImage and display the image...

What I want to do is get rid of the saving and loading, and just use the dbMakeImageFromMemblock command... but I can't find an officiant way to do this.

I Have tried using the dbWriteMemblockByte command and writing each channel of each pixel to the relevant byte, but it takes about 30 seconds to do each render, where as using the save image command I can render around 20 times a second.

Any help is appreciated!

Yours
N3wton

dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 17th Sep 2010 05:21
There's a function like dbGetMemblockPtr() or similar, using this pointer would allow you to get the start of the memblock, you can then call memcpy() to copy your data across, the header for memblock images is 12bytes, so make sure you account for this when copying.

N3wton
15
Years of Service
User Offline
Joined: 3rd Jun 2009
Location: Leeds, UK
Posted: 17th Sep 2010 12:17 Edited at: 17th Sep 2010 12:24
Thanks for the response...

I Think I've almost got it,



Thats what I'm using, but all I get is a white square

any ideas?

EDIT:

Think I Know The Problem, I'm in a RGBA format, and the makeimagefrommemblock wants it in a ARGB format?

Yours
N3wton

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 17th Sep 2010 16:23
Width, height and depths are DWORDS not bytes, and depth should be one of the constants from the help files, not 4.

[b]
Cuddle Bunniezzz 12
15
Years of Service
User Offline
Joined: 14th Jan 2009
Location: Buffalo, NY
Posted: 17th Sep 2010 22:49
Um, on a slightly un-related note:

Can someone tell me what a memblock is? (And why they are useful?)

http://ref.darkgdk.us/ <- Online DarkGDK Refernece. More content coming soon.
N3wton
15
Years of Service
User Offline
Joined: 3rd Jun 2009
Location: Leeds, UK
Posted: 18th Sep 2010 10:32
It's what it says it is basically... a block of memory... means you can change sounds images and more, and do stuff without having to save it and load it, you can do it straight to the memory...

Yours
N3wton

Cuddle Bunniezzz 12
15
Years of Service
User Offline
Joined: 14th Jan 2009
Location: Buffalo, NY
Posted: 19th Sep 2010 20:01
I did a little reading in my old DBPro book.

So are memblocks kind of like memory that you allocate using the malloc() function in the C Lib?

http://ref.darkgdk.us/ <- Online DarkGDK Refernece. More content coming soon.
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 20th Sep 2010 01:53
Yeah I think they are just memory from the heap allocated using new and deallocated with delete[]. Theres not much point in them in C++ really, would be better to allow you to directly pass pointers to DGDK.

Login to post a reply

Server time is: 2024-11-19 18:38:28
Your offset time is: 2024-11-19 18:38:28