I might niot be 100% on what oytu're after, but it sounds like you just want to be able to allow the user to pick fropm a limited (i.e. 256 colours) selection?
Something I worked with before I dived in and wernt with the 'full' colour-picker of Blitzsys was simply create with code or draw in paint a 16*16 image with all of the colour range you want, then have a function which grabs the data either by GetColor from the image as displayed, or, perhaps if it's a code-generated palette, as a formulae of the X/Y location on the palette iage:
if thius isn't so clear, here's a sample of some code:
Graphics 800,600
SetBuffer BackBuffer()
Global Palette=BuildPalette()
Global CurrentRed=255
Global CurrentGreen=255
Global CurrentBlue=255
While Not KeyDown(1)
DrawImage Palette,GraphicsWidth() - ImageWidth(Palette),0
Color 255,255,255
Rect 0,0,128,64,False
Color CurrentRed,CurrentGreen,CurrentBlue
Rect 1,1,126,62,True
If (MouseDown(1))
If ((MouseX()>(GraphicsWidth() - ImageWidth(Palette))) And (MouseY()<ImageHeight(Palette)))
PickColor(MouseX(),MouseY())
End If
End If
Flip
Wend
End
Function BuildPalette()
Local PaletteImage=CreateImage(64,64) ; Note 64 is used instead of 16, single pixels are likely too small to select accurately witht he mouse cursor.
SetBuffer ImageBuffer(PaletteImage)
Local IterRed=0
Local IterGreen=0
Local IterBlue=0
For IterRed=0 To 7
For IterGreen=0 To 7
Color IterRed Shl 6,IterGreen Shl 6,IterBlue Shl 6
Rect IterRed Shl 2,IterGreen Shl 2,4,4,True
Next
Next
IterGreen=0
For IterRed=8 To 15
For IterBlue=0 To 7
Color (IterRed-8) Shl 6,IterGreen Shl 6,IterBlue Shl 6
Rect IterRed Shl 2,IterBlue Shl 2,4,4,True
Next
Next
IterRed=0
For IterGreen=0 To 7
For IterBlue=8 To 15
Color IterRed Shl 6,IterGreen Shl 6,(IterBlue - 8) Shl 6
Rect IterGreen Shl 2,IterBlue Shl 2,4,4,True
Next
Next
For IterGreen=8 To 15
For IterBlue=8 To 15
Color (IterBlue - 8) Shl 6,(IterBlue - 8) Shl 6,(IterBlue - 8) Shl 6
Rect IterGreen Shl 2,IterBlue Shl 2,4,4,True
Next
Next
SetBuffer BackBuffer()
Return PaletteImage
End Function
Function PickColor(X,Y)
GetColor X,Y
CurrentRed=ColorRed()
CurrentGreen=ColorGreen()
CurrentBlue=ColorBlue()
End Function
|