|
-
Aug 11th, 2001, 11:24 AM
#1
Thread Starter
Frenzied Member
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
-
Aug 11th, 2001, 01:01 PM
#2
Good Ol' Platypus
VB Code:
[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:
Dim Pal(0 to 255) As PALETTEENTRY
Dim dPal As DirectDrawPalette
Set dPal = [DIRECTDRAWSURFACE7].GetPalette
Call dPal.GetEntries(0, 256, Pal())
To set the palette (which actually works, ), use this code:
VB Code:
Dim Pal(0 to 255) As PALETTEENTRY
Dim dPal As DirectDrawPalette
Call dPal.SetEntries(0, 256, Pal())
[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)
-
Aug 12th, 2001, 07:45 AM
#3
Good Ol' Platypus
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)
-
Aug 12th, 2001, 02:52 PM
#4
Thread Starter
Frenzied Member
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?
-
Aug 12th, 2001, 07:01 PM
#5
Good Ol' Platypus
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)
-
Aug 13th, 2001, 07:00 AM
#6
Thread Starter
Frenzied Member
Hum... in exactly which line does it crash? It will be easier to find the source of the problem if we know that.
-
Aug 13th, 2001, 07:06 AM
#7
Good Ol' Platypus
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 13th, 2001, 07:15 AM
#8
Thread Starter
Frenzied Member
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
-
Aug 13th, 2001, 10:07 AM
#9
Good Ol' Platypus
Yes, it is. And I set the surface with the palette indexed 8 flag...
VB Code:
Call dd.SetCooperativeLevel(Me.hWnd, DDSCL_FULLSCREEN Or DDSCL_EXCLUSIVE Or DDSCL_ALLOWREBOOT)
Here is the surface loading:
VB Code:
Public Function LoadBitm(ByRef Surf As DirectDrawSurface7, ByRef desc As DDSURFACEDESC2, File As String, Optional Paletted As Boolean = False)
If Paletted = True Then desc.ddpfPixelFormat.lFlags = DDPF_PALETTEINDEXED8
desc.lFlags = DDSD_CAPS
desc.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
Set Surf = dd.CreateSurfaceFromFile(File, desc)
End Function
VB Code:
Call LoadBitm(mySurf,myDesc,App.Path & "\chara.bmp",True)
And I use this:
VB Code:
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)
-
Aug 14th, 2001, 10:24 AM
#10
Thread Starter
Frenzied Member
Well, if you need to NOT be in exclusive mode to use that function, simply don't run your program in exclusive mode
-
Aug 14th, 2001, 08:32 PM
#11
Good Ol' Platypus
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)
-
Aug 20th, 2001, 12:27 PM
#12
Thread Starter
Frenzied Member
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.
-
Aug 20th, 2001, 10:48 PM
#13
Good Ol' Platypus
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)
-
Aug 22nd, 2001, 08:17 AM
#14
Thread Starter
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|