Results 1 to 6 of 6

Thread: Texture + Bitmap + GDI drawing

  1. #1

    Texture + Bitmap + GDI drawing

    Hi PGD Guys

    I have a few questions:

    I want to create a texture using D3DXCreateTextureFromFileInMemory but how can i setup a bitmapfile in memory
    What datastructures to use? :?

    Secondly i want to perform GDI drawing operations on that bitmap. So when i've changed the bitmap, i can upload it again to video RAM to apply the changes.

    Can someone provide me with some info on how to setup a bitmap, draw on it using GDI stuff and loading it using D3DXCreateTextureFromFileInMemory.

    Thank you

    BTW: is there a way to reload a texture from ram. (if that's possible, i dont have to create a new one , each time it must be updated)
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  2. #2

    Texture + Bitmap + GDI drawing

    ah... i've just figured it out myself :lol:

    I've modified the Texturing tutorial in Clooties SDK.
    Here is a piece of code:

    [pascal]
    var BMP: TBitmap;
    Memstream: TMemoryStream;
    begin
    BMP := TBitmap.Create;
    MemStream := TMemoryStream.Create;
    try
    BMP.LoadFromFile('banana.bmp');
    BMP.SaveToStream(MemStream);

    if FAILED(D3DXCreateTextureFromFileInMemory(
    g_pd3dDevice,MemStream.Memory^,MemStream.Size,g_pT exture))
    then Exit;
    finally
    MemStream.Free;
    BMP.Free;
    end;
    ...
    [/pascal]

    It's easier then i thought. You just keep the Bitmap in ram, change it, and update it using a MemoryStream. Pascal is sooow easy

    Have fun.

    EDIT: the only disadvantage is that you have to create a new texture for each update... Is there a way to update the pixeldata from a TBitmap to the texture :?
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  3. #3

    Texture + Bitmap + GDI drawing

    Quote Originally Posted by chronozphere
    the only disadvantage is that you have to create a new texture for each update... Is there a way to update the pixeldata from a TBitmap to the texture :?
    You can lock that D3D texture and copy pixels from bitmap into it. Lock gives you pointer to texture data so you can use Move to copy data here (from Bitmap.Scanline). Texture and bitmap pixel formats must be the same of course.
    Vampyre Imaging Library
    Earth Under Fire (PGD Big Boss 3rd place)
    Domains Of Chaos (PGD Multiplexity 5th place)

  4. #4

    Texture + Bitmap + GDI drawing

    ?łeah thanx... That should work for 32bit A8R8G8B8 textures, i think
    but it raises another question:

    How is the pixeldata stored in a 16bit bitmap??
    Is it like R5G6B5 or X1R5G5B5 or some other format??
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  5. #5

    Texture + Bitmap + GDI drawing

    Most 16bit bitmaps are in X1R5G5B5 format but bitmap files can store R5G6B5, A4R4G4B4, and more formats too (uses custom channel bitmasks). I've just briefly looked at VCL TBitmap and seems that it uses pf15Bit for X1R5G5B5 bitmaps, pf16Bit for R5G6B5, and pfCustom for 16bit bitmaps with other channel masks.
    Vampyre Imaging Library
    Earth Under Fire (PGD Big Boss 3rd place)
    Domains Of Chaos (PGD Multiplexity 5th place)

  6. #6

    Texture + Bitmap + GDI drawing

    Thank you very much :razz:

    That's the info i needed
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •