CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: realize palette

  1. #1
    Guest

    realize palette

    I had hard time to realize my palette. Following is the sub. The Result always
    gives me "0" which means none of my palette entries was realized. Anybody can tell why?

    --------------
    Sub SetColorScheme()
    Dim PlanesSrc As Long
    Dim PaletteSizeSrc As Long
    Dim LogPal As LOGPALETTE
    Dim ib As Integer
    Dim bb As Byte
    Dim lpPal As Long
    Dim Result As Long
    Dim R as Long

    ' Create a copy of the logic palette and realize it if necessary.
    LogPal.palVersion = &H300
    LogPal.palNumEntries = 256

    For ib = 0 To 255
    bb = ib
    LogPal.palPalEntry(bb).peRed = bb
    LogPal.palPalEntry(bb).peGreen = bb
    LogPal.palPalEntry(bb).peBlue = 255 - bb
    LogPal.palPalEntry(bb).peFlags = 0
    Next ib
    hPal = CreatePalette(LogPal)

    ' Select the palette into the destination and realize it.
    hPalPrev = SelectPalette(Pic.hdc, hPal, False)

    Result = RealizePalette(Pic.hdc)
    R = SelectPalette(Pic.hdc, hPalPrev, True)
    R = DeleteObject(hPal)

    End Sub


  2. #2
    Join Date
    Oct 2000
    Location
    Australia
    Posts
    12

    Re: realize palette

    i get the same problem.... i'd love an answer too. I switched the order of a few instructions (which probably is a bad thing anyways), and got a few nonzero returns from the functions, but then i get an overflow when i try and select the palette in.. dunno why. any help for this problem is appreciated!

    -Steins

    -Steins

  3. #3
    Join Date
    Oct 2000
    Location
    Australia
    Posts
    12

    Re: Realize palette - Moreinfo

    Heres my code...


    Dim lPal as LOGPALETTE
    Dim hPal as Long

    ''Create the Palette Entries
    ''Greyscale
    Dim palEntry(256) as PALETTEENTRY
    Dim counter as Integer
    for counter = 0 to 255
    palEntry(counter).peBlue = counter
    palEntry(counter).peRed = counter
    palEntry(counter).peGreen = counter
    palEntry(counter).peFlags = 0
    next counter

    ''Create a Logical Palette
    lPal.palVersion = &H300
    lPal.palNumEntries = 256

    Dim result as Integer

    Picture1.Image.hPal = hPal
    hPal = CreatePalette(lPal)
    result = SetPaletteEntries(hPal, 0, 256, palEntry(0))
    result = SelectPalette(frmMain.Picture1.hdc, hPal, false)
    result = RealizePalette(hPal)




    And it gets an overflow on the SelectPalette... help! :-)

    -Steins

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

Featured