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 / Image to Image

Author
Message
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 14th May 2005 09:13
Hey there

I *really* need to be able to paste images into images and quite speedily. I intend to be using locked textured plains for a gui and I will need to modify that texture in cases like say pasting icons into an inventory screen.

I tried to have a go at doing it with directX manually and from what I understand my code IS correct. But it throws an error caused by the fact my surfaces arnt in the default memory pool :/ to my knowledge the memory pool is set when the texture is created and I cant do anything to change it.. but I remember an image enchance or something dll that was floating around and im sure it had image to image functionality?

Take a look at my code:



As you can see it makes use of some of the db internal functions. I guess what i'm after is someone like Rich to tell me if im totally barking up the wrong tree with the way im trying to do this? Is it even possiable? :/

All responses welcome, im stuck.

[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th May 2005 11:33
I suppose you could say that I had a hand in the making of the image plug-in. I worked out some of the principals.

I don't know if you can blit between textures, so you may not be able to get this to work.

First, try using dbGetImagePointer.
If that doesn't work, then you may need to lock each surface, and copy the data from one image to the other with your own code.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 14th May 2005 11:51
error C2065: 'dbGetImagePointer' : undeclared identifier

and indeed the only function with the word Pointer in its name in the image header is dbGetPointer() which does return a dx9 texture So i guess this is just one of those weirdly named function thingys going on (im still using darksdk 1.0 here, collision kthx)

Well i have been talking with apex in the channel, we attempted to fix it but still to no avail. Its because the textures arnt being created with the D3DPOOL_DEFAULT flag (as far as we can tell). I tried to make my own textures specifying that flag using the dbMakeUsage() (me and apex are just GUESSING at what we can use these functions for, that doesnt help things) and then copying the image data from the src/dst into these new textures, performing the paste and copying the temp dest back to the original dest. It didnt work.

Still the same memory pool error in the output window, apprantly now my rects are invalid which is BS as i didnt change them oh and i get an assertion at the end now joy!

for those that would care to see it, my second attempt at the function:



I dont know which of my two attempts was closer to reaching the goal or if both of them are miles off. This is just SO frustrating. Has no one ever wanted to create a texture on the fly fast enough to be used at runtime before? :/ I would give my right hand to see a ImageToImage function in dgsdk/dbp T_T

Im trying to avoid memblocks because although editing the data in them is fast as hell I find creating memblocks and then creating objects (like images) from them is not fast enough to do in any large amount during runtime.

What do people suggest I do? Give up? Any other ideas? I guess i could try and do the pixel pushing method you just mentioned Ian. Setting the Lock parameter of dbGetImageData() should allow me to manually access the data in the pointer right? That might be fast enough.

Right now im narrowing my eyes both at MS for making surface to surface copying such a darn pain and slightly narrowing at tgc for the lack of this functionality - though i sympathise and cant blame them, I can see first hand by doing this perhaps why we dont have this functionality --;

[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th May 2005 08:17
No, it's definitely dbGetImagePointer in 1.1 - is dbGetPointer the name for the function in 1.0?

Quote: "Setting the Lock parameter of dbGetImageData() should allow me to manually access the data in the pointer right?"

Yep. I posted the code for a plug-in somewhere that shows how to do some of this. I can't find the post, but google was good enough to provide a link to the file I uploaded

http://forum.thegamecreators.com/xt/xt_apollo_download.php?i=530488

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk

Attachments

Login to view attachments
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 17th May 2005 17:28 Edited at: 17th May 2005 17:31
Well, thanks to your brilliant source Ian (many MANY thanks!) i'm ALMOST there. I am actually copying image data from one image to another atm Having a few final problems though which im sure are to do with my memory calculations.

if i copy onto the destination image at 0,0 - fine and perfect. but as i start moving the destination x/y around pixels start shifting also. As best I can tell the image remains the correct width and height, but a yellow pixel appears where a black one should be (my source image is a yellow 32x32 square with a smiley face crudly painted on top ) and vice versa. they just seem to get nudged around a bit. I dont know why.

I have so many copies of this function trying different things atm but they all suffer the same error. I'll post the function for you to look at.

This first function does the copying line by line - as im sure that is the fastest method I would like this one working the most



and just incase its any use, heres one that does the image copying pixel by pixel:



They both suffer the same "stray" pixel problem where as i change the x/y vars that are passed to the function the image skews in different ways.

Any ideas on how I can fix this? Im so close!

Thanks ^^

[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th May 2005 21:11
You code doesn't take any account of whether you are running in 16 or 32 bit mode. Running that code in 16 bit mode could explain your results.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 17th May 2005 21:54 Edited at: 17th May 2005 21:55
i didnt add a check for which colour mode i was in yet because i know im in 32bit depth. I was going to add those checks later.

But just incase I did this rather elaborate form of depth checking (i cant find a way to simply return the bpp of a surface!) plus after a moments thought I added a check to check the source and dest were the same format.



None of the two message box's get shown so the surfaces are the same format and it finds the format in my list of the unsigned formats. I still get my weird pixel nudging going on -_-

It sucks to be so close yet still far enough away for it to suck hard T_T Any ideas?

[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 19th May 2005 20:15
well I just discovered something - my function works perfectly XD I just forgot to set the flag to disable texture related operations when loading the image!

gawd.

ohwell, thanks ian, I have an excellent function thanks to you

[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol

Login to post a reply

Server time is: 2023-11-28 18:36:16
Your offset time is: 2023-11-28 18:36:16