Loading Texture from Bitmap object

maZZoo

Newcomer
Joined
Feb 2, 2005
Messages
2
I am working on a project, where I am trying to build a (large) 2D map with Icons on it.

This works ok, untill I try to load map file (a 2500x2500 file), then my Texture.FromBitmap function crashes with the error message:
-2005530516 (D3DERR_INVALIDCALL)
in line:
m_TextureHash[ imageName ] = Texture.FromBitmap( m_Device, theImage, 0, Pool.Default );

It works if I insted do this:
TextureLoader.FromFile( m_Device, path );

But I want to manipulate the Image object, before I load the texture. How can I do this ?

Thx in advance,
-maZZoo
 
Have you tried explicitly loading textures into the managed pool? I don't know if that is the problem, but I have seen similar issues.

[Vb]
m_TextureHash[ imageName ] = Texture.FromBitmap( m_Device, theImage, 0, Pool.Managed);
[/CODE]
 
Thx for the idea unfortunally I have tryed that, and it does not seem to work,
maybe its because of the large memory consumsion it requires ?

I've gotton this to work (sort of)

Code:
m_TextureHash[ imageName ] = TextureLoader.FromFile( m_Device, imageName );

Only problem is, that it converts the image to a by 2 number ( eg 2048x2048 insted of the original 2500x2500 )

So I cannot use that,
Hope that somebody out there have a answer !

-maZZoo
 
Hi Mazzoo,
I'm working on what sounds like a similar project. I have large 2D images (10000x10000) onto which I want to draw additional stationary items and also some moving items. The user can then scroll around this composite image. I ran into similar problems with Textures as powers of 2 and size limitations imposed by my Graphics Card (2048x2048 max).

I did think of using DirectDraw but the MSDN warnings plus having to convert my jpg to a bmp to load it made me shy away and plunge into Direct3D.

Ken Paulson over at http://www.drunkenhyena.com/ supplied me with the scheme for a solution. (Ken's site is being revamped and I think the DirectX Tutorials are still offline). However, it goes like this:

(I have large images now being displayed in a picturebox with the user scrolling them.)
Create a Texture (same size as your picturebox say)
boximage=Textureloader.fromfile(Device,TextureFile)
Create a surface to hold your Map image
backbuffer=graphicsdevice.CreateOffscreenPlainSurface(............
Load your map Image onto this surface
surfaceloader.FromFile(backbuffer,..................
Get a surface from your Texture
imgsurface=boximage.getsurfacelevel(0)
Load this surface with the "visible" part of your Map Image Surface
surfaceloader.FromSurface(imgsurface,backbuffer,.........
Then I use Sprite.Draw2D in my Render routine.

This works really well. Now where I'm stuck is in being able to draw lines & rounded boxes on my Map Image surface (ie Backbuffer).

Hope this helps.
 
Last edited:
Back
Top