Jump to content
  • Advertisement
Sign in to follow this  
hindmano

[Solved]Texture Copying need smart person input!

This topic is 3790 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

System.Drawing.Bitmap FullTileset = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromFile(@".\Graphics\" + TileFileName); System.Drawing.Bitmap Temp; int Count = 0; Bitmap temp1 = new Bitmap(256, 4096); Bitmap temp2 = new Bitmap(64, 64); for (int y = 0; y <= 63; y++) { for (int x = 0; x <= 3; x++) { Temp = FullTileset.Clone(new RectangleF(x*64, y*64, 64, 64), System.Drawing.Imaging.PixelFormat.Format32bppArgb); TileTexture[Count] = Texture.FromBitmap(device, Temp, Usage.None,Pool.Managed); Count++; } } This is how i load 255 Textures from one big one at 256*4096 (Master Tile File) to 255 64*64 Textures currently. The problem is this they are being used for sprites and since i am using managed directx x 9 lots of stuff has changed with sprites and copyrect etc, i need to use color keys so i can use transparent sprites. Any suggestions ? i have heard you can load everything into a surface and the use GetSurfaceLevel(0) to do a direct copy retaining colorkey info etc but i just dont know enough about it to make it work i really need some kind of a sample. Any help would be most welcome and i know this is the place that all the smart nice helpfull guys hang out :) if you need or want more src let me know. [Edited by - hindmano on February 7, 2008 10:10:10 PM]

Share this post


Link to post
Share on other sites
Advertisement
EKSprite.Draw(Hud1, Vector3.Empty, new Vector3(0,0,0),Color.Black.ToArgb());

That is what i am using for drawing my sprites btw.

as a side note i have been working on this for several days before i posted here and also this account is new because my old one is hosed after that hacking crap.



Share this post


Link to post
Share on other sites
hmm well either i did or said something wrong or no one here knows? i find the later hard to believe, so what did i do or forget to say in my above posts?

Share this post


Link to post
Share on other sites
Quote:
Original post by hindmano
so what did i do or forget to say in my above posts?
You forgot to wait more than 2 hours. These forums are reasonably busy, but not constantly. I for one was asleep (It's now 9:30am here). It's usually a good idea (And ISTR it's in one of the forum FAQs) that you should wait 24 hours before bumping your post.

Anyway, what is the actual problem? You don't have a colour key on the new textures, but you need one?
Are you loading the original file as a texture? What is the type of FullTileset? If it's a texture, you should (probably) just be able to load it with a colour key then copy bits out of it into the new textures.

Bitmaps don't have alpha in them (As far as I know), so you'll either have to use surfaces instead of bitmaps, or perform the colour keying after creating the texture (By locking it and updating the alpha).

I'm not a MDX person, so I can only answer your questions generally.

Share this post


Link to post
Share on other sites
okay first off thanks for the response, second my first 2 posts were on 2/2 just minutes apart i posted again with more information not trying to "bump' anything and that was 2 days ago. but i am still glad for the reply.


currently i am loading the full image into a bitmap objcect then cloning sections to texture objects.

and yes there is no colorkeying or alpha transfered that way.

i would love to find an alternate method of doing it to be able to set and use a color key.

i have tried loading an image to a surface and using stretchrect to display it but i am still not getting transparency, example:

m_surface = device.CreateOffscreenPlainSurface( 425, 617,Format.A8R8G8B8,Pool.Default );

SurfaceLoader.FromFile(m_surface, @".\Data\EKMenu1.bmp",Filter.None,Color.Black.ToArgb());

Surface backbuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono);

device.StretchRectangle(m_surface,new Rectangle(0, 0, 425, 617),backbuffer,new Rectangle(299, 76, 425,617), TextureFilter.Point);

backbuffer.Dispose();

in that image i have a square of black (0,0,0) a square of white (255,255,255) and a square of transparent and using photoshop saving as a bmp using advanced 32 bpp it lets me save in A8R8G8B8 format, but still nothing what am i missing.

thanks in advanced
Owen Hindman

Share this post


Link to post
Share on other sites
or how about this to make it simpler assume you have a image ( whatever format works is fine ) that has a black (0,0,0) that needs to be transparent. can you show me some code that would load it to a surface and render it correctly, with the black parts not being drawn etc. i can program in c or whatever so i can change the functions over to c#. there is something i am missing and it is driving me insane :) and i have scowered google and and the tutorial sites and books that i have and it is still evading me :)

Share this post


Link to post
Share on other sites
Quote:
Original post by hindmano
using photoshop saving as a bmp using advanced 32 bpp it lets me save in A8R8G8B8 format

Support for this file format seems iffy at best to me; I've never been able to get it to work. Before worrying about anything else, why don't you try saving as a .TGA or a .PNG and see if that works? Photoshop treats them a little bit differently so make sure your file is saved correctly before assuming you have coding errors; I like to use Windows Image Preview or some other external program for this purpose. (For PNG, Photoshop likes you to have just one 'layer' with transparency in it as you choose. For TGA, it prefers that you have the regular 24-bit background with an additional 8-bit alpha channel. At least in version 6.0, not sure about newer ones.)

Share this post


Link to post
Share on other sites
Found a work around . i am now just loading the master tile file into the one big texture and then using sprite.draw to just draw a portion of it and it seems to be holding the color key stuff that way and seems to be pretty fast so if anyone needs any samples feel free to email me at owenla@hotmail.com


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!