KeyedSurface

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
JerryTheBig
Posts: 33
Joined: July 27th, 2012, 12:48 pm

KeyedSurface

Post by JerryTheBig » July 5th, 2013, 10:33 pm

Hi,
keyedsurface does not work properly. I have tried to solve it using breakpoints and I found out that D3DCOLOR c = surface[ x+y * width]
gets wrong pixel color.
I also tried different colors and different pics. Nothing worked.
There are other ways how to aplly transparency but I want to solve why this doesnt work.

Thank you for help.
Code attached below.
Attachments
Platformer.rar
(1.99 MiB) Downloaded 132 times

JerryTheBig
Posts: 33
Joined: July 27th, 2012, 12:48 pm

Re: KeyedSurface

Post by JerryTheBig » July 5th, 2013, 11:29 pm

OK, got it. Can somebody tell me why it does not work with d3dcolor but with D3DCOLOR_XRGB(255, 0, 255) does?

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: KeyedSurface

Post by LuisR14 » July 6th, 2013, 8:40 am

most prolly because you're loading a 24-bit image, so gdiplus sets the alpha channel to 255
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

JerryTheBig
Posts: 33
Joined: July 27th, 2012, 12:48 pm

Re: KeyedSurface

Post by JerryTheBig » July 6th, 2013, 10:19 am

And what is what? I dont know much about this issue.

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: KeyedSurface

Post by LuX » July 6th, 2013, 11:32 am

I couldn't really find where exactly the problem comes up, but I'm assuming that you are talking about the purple stuff around your tiles showing up. You also say that the problem goes away when you put "D3DCOLOR_XRGB(255, 0, 255) " somewhere.

Assumptions: The purple stuff is your problem. the color just so happens to be R:255 B:0 G:255, so it probably fixes it because you are telling the program to not draw any pixels of the image that have that color (purple) there fore it solves the problem because you are not drawing the purple pixels. That's keyed surface.
ʕ •ᴥ•ʔ

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: KeyedSurface

Post by LuisR14 » July 6th, 2013, 12:07 pm

hmm, i get it now, since that color (which is magenta btw) is used mostly for transparency (hardly ever used color haha) he just thought it would just make it transparent automatically (since some programs handle that color to be like that)
but yea it doesn't work that way, since that color is like Lux said R:255 G:0 B:255 and A:255 (if you want to include alpha channel lol)
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

Post Reply