Q: using and changing the 256 color palette... 
Author Message
 Q: using and changing the 256 color palette...

Quote:

> Option Explicit
> Type PALET{*filter*}TRY
>     peRed As String * 1   'Byte
>     peGreen As String * 1 '
>     peBlue As String * 1   'byte
>     peFlags As String * 1   '
> End Type

> Type LOGPALETTE
>     palVersion As Integer
>     palNumEntries As Integer
>     palPalEntry(255) As PALET{*filter*}TRY ' Enough for 256 colors
> End Type

> Declare Function SelectPalette Lib "User" (ByVal hDC As Integer, ByVal hPalette As Integer, ByVal bForceBackground As Integer) As Integer
> Declare Function setPalet{*filter*}tries Lib "GDI" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPalet{*filter*}tries As PALET{*filter*}TRY) As Integer
> Declare Function CreatePalette Lib "GDI" (lpLogPalette As LOGPALETTE) As Integer
> Declare Function RealizePalette Lib "User" (ByVal hDC As Integer) As Integer
> Declare Function GetDC Lib "User" (ByVal hWnd As Integer) As Integer

> Sub Command4_Click ()
> Dim resultat As Long
> Dim LogPal As LOGPALETTE
> Dim xxx As Integer
> Dim r As Long
> Dim r_farge As String * 1
> Dim b_farge  As String * 1
> Dim g_farge As String * 1
> Dim hPal As Integer
> Dim hPalPrev As Integer

>       LogPal.palVersion = &H300
>       LogPal.palNumEntries = 100

>       'building 100 colors in palette....(works !)
>       For xxx = 0 To 100
>       LogPal.palPalEntry(xxx).peRed = Chr$(0 + (xxx * 2))'
>       LogPal.palPalEntry(xxx).peGreen = Chr$(255 - (xxx * 2)) '
>       LogPal.palPalEntry(xxx).peBlue = Chr$(255 - (xxx)) ' + (xxx * 2))'
>       logPal.palPalEntry(xxx).peFlags = Chr$(0)
>       Next xxx

>       resultat = setPalet{*filter*}tries(hPal, 0, 100, LogPal.palPalEntry(0))
>       hPal = CreatePalette(LogPal)
>       hPalPrev = SelectPalette(form1.hDC, hPal, 0)
>       r = RealizePalette(form1.hDC)

>       r_farge = LogPal.palPalEntry(51).peRed
>       g_farge = LogPal.palPalEntry(51).peGreen
>       b_farge = LogPal.palPalEntry(51).peBlue
>       form1.Caption = Str$(Asc(r_farge))

>       picture2.Line (0, 0)-(2000, 2000), RGB(Asc(r_farge), Asc(g_farge), Asc(b_farge)), BF

> End Sub


                                                                       
Name:   Atle Iversen                  _/_/    _/   _/    _/   _/    _/
                                      _/ _/   _/   _/    _/   _/    _/  

Norges Handelsh?yskole             _/   _/ _/   _/    _/   _/    _/    
Norwegian School of Economics &    _/    _/_/   _/    _/   _/    _/    
Business Administration                                                
Adress: Bergen,Norway                                                  



Fri, 29 Aug 1997 16:49:55 GMT  
 Q: using and changing the 256 color palette...
I'm sorry, but my questions disappeared somewhere along the way. Anyway,
thanks for the responses to my questions about 256 colors.
Unfortunately, as I'm not an API-expert, I haven't been able to solve
this problem. The code included is able to change the palette (I've
checked !) but my problem is: How to I use the &%#&% colors from the
palette ????? When I use line...BF with an rgb value from the table, I
still don't get SOLID colors, only dithered......

Please, please look at my code, and if anyone have an idea about what's
wrong, please give me a hint. I've been banging my head all weekend, and
I'm about to give up this &%&#%%&.

Thank you
Atle I

Quote:

>> Option Explicit
>> Type PALET{*filter*}TRY
>>     peRed As String * 1   'Byte
>>     peGreen As String * 1 '
>>     peBlue As String * 1   'byte
>>     peFlags As String * 1   '
>> End Type

>> Type LOGPALETTE
>>     palVersion As Integer
>>     palNumEntries As Integer
>>     palPalEntry(255) As PALET{*filter*}TRY ' Enough for 256 colors
>> End Type

>> Declare Function SelectPalette Lib "User" (ByVal hDC As Integer, ByVal hPalette As Integer, ByVal bForceBackground As Integer) As Integer
>> Declare Function setPalet{*filter*}tries Lib "GDI" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPalet{*filter*}tries As PALET{*filter*}TRY) As Integer
>> Declare Function CreatePalette Lib "GDI" (lpLogPalette As LOGPALETTE) As Integer
>> Declare Function RealizePalette Lib "User" (ByVal hDC As Integer) As Integer
>> Declare Function GetDC Lib "User" (ByVal hWnd As Integer) As Integer

>> Sub Command4_Click ()
>> Dim resultat As Long
>> Dim LogPal As LOGPALETTE
>> Dim xxx As Integer
>> Dim r As Long
>> Dim r_farge As String * 1
>> Dim b_farge  As String * 1
>> Dim g_farge As String * 1
>> Dim hPal As Integer
>> Dim hPalPrev As Integer

>>       LogPal.palVersion = &H300
>>       LogPal.palNumEntries = 100

>>       'building 100 colors in palette....(works !)
>>       For xxx = 0 To 100
>>       LogPal.palPalEntry(xxx).peRed = Chr$(0 + (xxx * 2))'
>>       LogPal.palPalEntry(xxx).peGreen = Chr$(255 - (xxx * 2)) '
>>       LogPal.palPalEntry(xxx).peBlue = Chr$(255 - (xxx)) ' + (xxx * 2))'
>>       logPal.palPalEntry(xxx).peFlags = Chr$(0)
>>       Next xxx

>>       resultat = setPalet{*filter*}tries(hPal, 0, 100, LogPal.palPalEntry(0))
>>       hPal = CreatePalette(LogPal)
>>       hPalPrev = SelectPalette(form1.hDC, hPal, 0)
>>       r = RealizePalette(form1.hDC)

>>       r_farge = LogPal.palPalEntry(51).peRed
>>       g_farge = LogPal.palPalEntry(51).peGreen
>>       b_farge = LogPal.palPalEntry(51).peBlue
>>       form1.Caption = Str$(Asc(r_farge))

>>       picture2.Line (0, 0)-(2000, 2000), RGB(Asc(r_farge), Asc(g_farge), Asc(b_farge)), BF

>> End Sub

>
>                                                                        
> Name:   Atle Iversen                  _/_/    _/   _/    _/   _/    _/
>                                       _/ _/   _/   _/    _/   _/    _/  

> Norges Handelsh?yskole             _/   _/ _/   _/    _/   _/    _/    
> Norwegian School of Economics &    _/    _/_/   _/    _/   _/    _/    
> Business Administration                                                
> Adress: Bergen,Norway                                                  
>



Fri, 29 Aug 1997 17:02:32 GMT  
 Q: using and changing the 256 color palette...

Quote:


writes:
>I'm sorry, but my questions disappeared somewhere along the way. Anyway,
>thanks for the responses to my questions about 256 colors.
>Unfortunately, as I'm not an API-expert, I haven't been able to solve
>this problem. The code included is able to change the palette (I've
>checked !) but my problem is: How to I use the &%#&% colors from the
>palette ????? When I use line...BF with an rgb value from the table, I
>still don't get SOLID colors, only dithered......

I have two helpful hints.

1. You went to much trouble to select the new palette into the form's
device context but the picture box, my friend, is using a different
device context. Try drawing to the form instead or munge the picture box
palette and draw to the picture box.

2. Lose the signature. I hate these damn long signatures, they clutter up
everyone's disks around the world.



Sat, 30 Aug 1997 13:33:52 GMT  
 
 [ 4 post ] 

 Relevant Pages 

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

2. Using 256 color Palettes in High/True Color

3. choose a color in a 256 color palette ?

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. color palette not accessible in 256+ color settings

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

9. 256 Color Palette

10. halftone palette/256 colors

11. Custom 256-color palettes - how??

12. 256 color palette with VB controls

 

 
Powered by phpBB® Forum Software