Results 1 to 16 of 16

Thread: Has anyone ever gotten Surface.GetPalette to work?

  1. #1

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134

    Has anyone ever gotten Surface.GetPalette to work?

    I've tried EVERYTHING, and nothing works. This is the code that's loading a 256-colour bitmap, in a 256-colour 640x480 fullscreen window:
    VB Code:
    1. 'Set Logo surfaces.
    2.     dLogo.lFlags = DDSD_HEIGHT Or DDSD_WIDTH Or DDSD_CAPS
    3.     dLogo.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
    4.     dLogo.ddpfPixelFormat.lFlags = DDPF_PALETTEINDEXED8
    5.     dLogo.lWidth = 640
    6.     dLogo.lHeight = 480
    7.    
    8.     Set Logo = DD7.CreateSurfaceFromFile(App.Path & _
    9.     "\resource\logo.bmp", dLogo)
    10.    
    11.     'Get Palette
    12.     Set SavePalette = Logo.GetPalette
    13.     SavePalette.GetEntries 0, 256, SavePalEntries()
    And it always gives me "Automation Error | Unspecified Error" highlighting the GetPalette method.

    Help...?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  2. #2

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Okay, an update.
    I added "Or DDSD_PIXELFORMAT" to the .lFlags parameter and now it's bombing out on the CreateSurfaceFromFile method, with "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)

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I guess there is no need in VB to zero out unused fields or set the size of structures, right?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Really... Please explain, I have the feeling you will be able to solve my problem
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    In C++, when I use any struct like DDSURFACEDESC2, I first have to do two things:
    Code:
    DDSURFACEDESC2 ddsd;
    ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
    ddsd.dwSize = sizeof(DDSURFACEDESC2);
    The first line is like
    Dim ddsd as DDSURFACEDESC2

    The second fills the complete struct with 0.
    The third sets the dwSize member (that's lSize in VB) to the length of the struct ( Len(DDSURFACEDESC2) ).

    Then I can set the members I need. If I don't do that, nothing will work.

    Now I suspect, since all DX calls are wrapped in VB, that you don't have to do that. Am I right?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6

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

  7. #7
    Junior Member
    Join Date
    Mar 2002
    Location
    England
    Posts
    23
    I think you might need to create your palette before you can "get" it...

    from my palettes tutorial:

    Set DDPalette = dd.CreatePalette(DDPCAPS_8BIT Or DDPCAPS_ALLOW256, Pal())

    - sure you're not ACTUALLY wanting to create the palette (fill it with the data from Pal() ), but i dont remember how DD operates internally... and I'm guessing that once you created it the GetPalette() call will just overwrite the data for you...

    Secondly, work out what the automation error is telling you - it may give you the hint that you need

    Jack;

  8. #8

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    I'll try that.
    This is, by the way, trying to do the same thing I had emailed you about last year.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  9. #9
    Junior Member
    Join Date
    Mar 2002
    Location
    England
    Posts
    23
    aah, oops

    i dont really remember the questions that people email me about...

    Jack;

  10. #10

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Thank you both for your advice, however it still gives me an Unspecified Automation Error whenever I run the code.

    This really bites

    Anyone have any source code of the GetPalette method in action?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  11. #11
    Junior Member
    Join Date
    Mar 2002
    Location
    England
    Posts
    23
    what do you mean by "Unspecified Automation Error"? you mean that you've dereferenced it to a DDERR_?? value + description, OR you're just leaving it as an automation error?

    Jack;

  12. #12

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Do you use the GetLastError thingey to get the error or something? I remember in DirectGraphics finding the error but I don't know about DirectDraw.

    God it's hard to type on this computer...
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  13. #13
    Junior Member
    Join Date
    Mar 2002
    Location
    England
    Posts
    23
    you basically need to parse through the whole list of errors, D3DX8 makes things easy - but DD7 was quite hard

    Check out this class module i 'wrote' - it'll output the description and error value.

    post that back here and I/someone can maybe help you out... or it may be obvious to you straight away...

    Jack;

  14. #14
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242
    I don't know if this will really help but I think I've noticed a little error in you're code, maybe.

    SavePalette.GetEntries 0, 256, SavePalEntries()

    The part saying "0, 256," is that supposed to mean get palette entries 0 through 256? If so that might be your problem. If you count starting with 0 then it would be 255 instead of 256.

    I don't know if this'll help, but hey, it's worth a try.



    Drewski

  15. #15
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I think it is a count, not an end point. You can still try.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  16. #16

    Thread Starter
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Nope, thanks anyway, but the program stops before that line and it is indeed the count.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

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