color palette not accessible in 256+ color settings 
Author Message
 color palette not accessible in 256+ color settings

I am trying to access the color palette of a bitmap image.
The bitmap is of less than 256 colors.

In 256 color mode it works fine but the moment i change my graphic/monitor
settings to 256+  (i.e. 32000+, 16 or24 bit true color)

I have tried many times but it does not seem to work. Please help!!!!!

Code runs like this :

' ######declarations

option explicit
Dim objPic As StdPicture
Dim tmpObjPic As StdPicture
Dim lbl() As Label

Public Type PALET{*filter*}TRY
        peRed As Byte
        peGreen As Byte
        peBlue As Byte
        peFlags As Byte
End Type

Public arrPalEntry(256) As PALET{*filter*}TRY

'#####end of declarations

Private Sub Form_Load()
    Set objPic = LoadPicture(App.Path & "\images\image1.bmp")
End Sub

Private Sub cmdPalette_Click()

Dim a As Integer
Dim i As Integer
Dim r As Integer
Dim cnt As Long
Dim vartop As Long
Dim varleft As Long

varCreatePalete = apiGetPalet{*filter*}tries(ObjPic.hPal, 0, 256, arrPalEntry(0))

'### draw 256 small labels on the form , each label.backcolor is equal to
the color in the corresponday array element.

    vartop = 216
    varleft = 70
    cnt = 0

    Dim cntTot As Long

    For a = 0 To 7
        r = 0
        varleft = 70
        vartop = 216 + a * 10 + (a * 7)
        For i = 0 To 32

            If cnt > 1 Then
                 Load lbl(cnt)         ' lbl() declared in general
declarations above
        End

 With lbl(cnt)
         .Appearance = 0
         .visible=false
          .Width = 10
          .Height = 10
        .Top = vartop
         .Left = varleft
 End With

             r = r + 1
             vartop = 216 + a * 10 + (a * 7)
             varleft = 70 + r * 10 + (r * 7)

             lbl(cnt).BackColor = RGB(arrPalEntry(cnt).peRed,
arrPalEntry(cnt).peGreen,                 arrPalEntry(cnt).peBlue)

             If cnt = 255 Then
                Exit For
             End If

             cnt = cnt + 1

        Next

        If cnt = 255 Then  ' two label controls already placed on the form
            Exit For
         End If
    Next

'#### displays the labels on the form
For i = 0 To cnt
    lbl(i).Visible = True
Next

End Sub



Sun, 07 Nov 2004 19:48:09 GMT  
 color palette not accessible in 256+ color settings
GetPalet{*filter*}tries() is looking for a System palette: there is none in
color modes above 256.  Try using the GetDIBColorTable() function
instead.

Jim Deutch
MS Dev MVP

On Wed, 22 May 2002 17:18:09 +0530, "Sandeep Kumar"

Quote:

>I am trying to access the color palette of a bitmap image.
>The bitmap is of less than 256 colors.

>In 256 color mode it works fine but the moment i change my graphic/monitor
>settings to 256+  (i.e. 32000+, 16 or24 bit true color)

>I have tried many times but it does not seem to work. Please help!!!!!

>Code runs like this :

>' ######declarations

>option explicit
>Dim objPic As StdPicture
>Dim tmpObjPic As StdPicture
>Dim lbl() As Label

>Public Type PALET{*filter*}TRY
>        peRed As Byte
>        peGreen As Byte
>        peBlue As Byte
>        peFlags As Byte
>End Type

>Public arrPalEntry(256) As PALET{*filter*}TRY

>'#####end of declarations

>Private Sub Form_Load()
>    Set objPic = LoadPicture(App.Path & "\images\image1.bmp")
>End Sub

>Private Sub cmdPalette_Click()

>Dim a As Integer
>Dim i As Integer
>Dim r As Integer
>Dim cnt As Long
>Dim vartop As Long
>Dim varleft As Long

>varCreatePalete = apiGetPalet{*filter*}tries(ObjPic.hPal, 0, 256, arrPalEntry(0))

>'### draw 256 small labels on the form , each label.backcolor is equal to
>the color in the corresponday array element.

>    vartop = 216
>    varleft = 70
>    cnt = 0

>    Dim cntTot As Long

>    For a = 0 To 7
>        r = 0
>        varleft = 70
>        vartop = 216 + a * 10 + (a * 7)
>        For i = 0 To 32

>            If cnt > 1 Then
>                 Load lbl(cnt)         ' lbl() declared in general
>declarations above
>        End

> With lbl(cnt)
>         .Appearance = 0
>         .visible=false
>          .Width = 10
>          .Height = 10
>        .Top = vartop
>         .Left = varleft
> End With

>             r = r + 1
>             vartop = 216 + a * 10 + (a * 7)
>             varleft = 70 + r * 10 + (r * 7)

>             lbl(cnt).BackColor = RGB(arrPalEntry(cnt).peRed,
>arrPalEntry(cnt).peGreen,                 arrPalEntry(cnt).peBlue)

>             If cnt = 255 Then
>                Exit For
>             End If

>             cnt = cnt + 1

>        Next

>        If cnt = 255 Then  ' two label controls already placed on the form
>            Exit For
>         End If
>    Next

>'#### displays the labels on the form
>For i = 0 To cnt
>    lbl(i).Visible = True
>Next

>End Sub



Mon, 08 Nov 2004 00:18:43 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Using 256 color Palettes in High/True Color

2. choose a color in a 256 color palette ?

3. Change Screen Color Palette from 256 to hi-color in VB

4. Bitmap Color Palette editing-VB4 16 bit 256 color

5. Coloring a control from a 256-Color palette

6. Coloring a control from a 256-Color palette

7. Bitmap Color Palette editing-VB4 16 bit 256 color

8. 256 Color Palette not sticking

9. grid congtrol not responding to 256 color palette requests

10. 256 Color Palette

11. halftone palette/256 colors

12. Custom 256-color palettes - how??

 

 
Powered by phpBB® Forum Software