Results 1 to 14 of 14

Thread: Need to load 8-bits images *AS 8-BITS IMAGES* in my 24-bits DX game!

  1. #1

    Thread Starter
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457

    Unhappy Need to load 8-bits images *AS 8-BITS IMAGES* in my 24-bits DX game!

    Hi!

    In my DX game (24-bits), I need to load a surface as 8-bits. But it won't let me - the surface appears as 24-bits! How can I specify the color depth to use, or use the color depth of the file?

    If you can't help me, please post some code chunks to load images in DX and I might be able to figure it out
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    VB Code:
    1. [DDSURFACEDESC2].ddpfPixelFormat.lFlags = DDPF_PALETTEINDEXED8

    This will denote it as a paletted surface. To get the palette entries (which isn't working for me, grrr ), you use this chunk of code:

    VB Code:
    1. Dim Pal(0 to 255) As PALETTEENTRY
    2. Dim dPal As DirectDrawPalette
    3. Set dPal = [DIRECTDRAWSURFACE7].GetPalette
    4. Call dPal.GetEntries(0, 256, Pal())

    To set the palette (which actually works, ), use this code:

    VB Code:
    1. Dim Pal(0 to 255) As PALETTEENTRY
    2. Dim dPal As DirectDrawPalette
    3. Call dPal.SetEntries(0, 256, Pal())
    4. [DIRECTDRAWSURFACE7].SetPalette dPal
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    BTW, why do you need to load them as 8-bit images?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4

    Thread Starter
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Thanks!

    I'd help you out with getting the palette entries, but VB doesn't seem to work now

    Can you please post here again so I get e-mailed and remember to check back tomorrow?
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  5. #5
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Well, if you want me to post here I am

    I looked this up (in a hurry!) because I want to be able to add a tinge to all of my sprites (to simulate sunset/sunrise/nighttime/daytime). The method that I (have tried!!) to use would be fast, but I dont know if it would be fast enough...
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  6. #6

    Thread Starter
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Hum... in exactly which line does it crash? It will be easier to find the source of the problem if we know that.
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  7. #7
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    .GetPalette
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  8. #8

    Thread Starter
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Hum DDraw usually crashes the whole comp with a small error... here are the 2 most likely causes of your problem:

    Code:
    DDERR_NOEXCLUSIVEMODE
    The operation requires the application to have exclusive mode, but the application does not have exclusive mode.
    
    DDERR_NOPALETTEATTACHED
    No palette object is attached to this surface.
    The first one is, I think, what is happening - is your game running in exclusive mode?

    Just a wild guess
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  9. #9
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Yes, it is. And I set the surface with the palette indexed 8 flag...
    VB Code:
    1. Call dd.SetCooperativeLevel(Me.hWnd, DDSCL_FULLSCREEN Or DDSCL_EXCLUSIVE Or DDSCL_ALLOWREBOOT)
    Here is the surface loading:
    VB Code:
    1. Public Function LoadBitm(ByRef Surf As DirectDrawSurface7, ByRef desc As DDSURFACEDESC2, File As String, Optional Paletted As Boolean = False)
    2.  
    3.     If Paletted = True Then desc.ddpfPixelFormat.lFlags = DDPF_PALETTEINDEXED8
    4.     desc.lFlags = DDSD_CAPS
    5.     desc.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
    6.     Set Surf = dd.CreateSurfaceFromFile(File, desc)
    7.    
    8. End Function
    VB Code:
    1. Call LoadBitm(mySurf,myDesc,App.Path & "\chara.bmp",True)
    And I use this:
    VB Code:
    1. Set PPal = mySurf.GetPalette
    If I use this code, I get an AUTOMATION error.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  10. #10

    Thread Starter
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Well, if you need to NOT be in exclusive mode to use that function, simply don't run your program in exclusive mode
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  11. #11
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Oh you're evil >=)
    I've decided to drop palettes, in order to use getlockedarray
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  12. #12

    Thread Starter
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    You can use that with palettes too, it's just gonna be a bit harder to use special effects or something (palettes is where lookup tables are the ONLY fast method to use).

    In 8-bits, each byte is a pixel (the palette index); in 16-bits, each 2 bytes are a pixel (this is a bit hard to use since you'll need to find out if the method is 555 or 556, and you'll have to use bitshifts to figure out the RGB values); in 24-bits, each 3 bytes are a pixel (each RGB value is a byte); and 32-bits is just like 24-bits, except that the fourth byte isn't used.

    Remember that a greater color depth means looping trough more bytes, so it's slower.
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  13. #13
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    I know that, for some reason my GeForce is lightning fast with that stupid Set/GetLockedPixel method (1/2 a second for 320x240), that's for my gradient function. Anyways I wont be toying with palettes for a long time, bring on the full-screen clippers >=(
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  14. #14

    Thread Starter
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Then you should ask MS about it!

    BTW, I need to load them as 8-bits for the damage indicator in my Tyrian game... I can't tell you here because someone could steal my idea

    You could also have the whole game in 8-bits mode and change the palette of the front surface or something... it would be a lot easier because this way you only have 1 palette so you can load it from a file
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

Posting Permissions

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



Click Here to Expand Forum to Full Width