Habe den Code da unten gefunden.
Wollte so vorgehen..
-Jedes Pixel mit Point einlesen
-das Pixel mit rgb in die Anteile für Rot Grün Blau zerlegen
-die Anteile mit @ an RGB2HSV übergeben
-den zurückgegebenen HSV Wert auslesen
...so bis dahin sollte es ja korrekt sein ?!??
-jetzt versteh ich aber nicht wie es weiter geht....
Muss ich jetzt was bei Drawingmode ändern ?
Kann ich den zurückgebenen HSV Wert einfach als RGB Farbe nehmen und drauf
los zeichnen oder muss ich da noch irgendwas extra setzen ?
Bisherige Versuche führten jedenfalls bisher nicht zum Erfolg.
Wie gesagt das Ziel ist ein Farbbild in ein HSV Bild umzurechnen.
Code: Alles auswählen
; English forum: http://purebasic.myforums.net/viewtopic.php?t=8251&highlight=
; Author: tinman
; Date: 08. November 2003
; RGB to HSV colour converter and back again
; From: http://astronomy.swin.edu.au/~pbourke/colour/hsv/
#USE_ASM_PROCEDURES=1
CompilerIf #USE_ASM_PROCEDURES=1
; Uses the MinF and MaxF functions posted to the tricks & tips forum by Psychophanta
Procedure.f MinF(n1.f,n2.f)
!finit
!fld dword[esp+4]
!fld dword[esp]
!fcomi st1
!fcmovnb st1
EndProcedure
Procedure.f MaxF(n1.f,n2.f)
!finit
!fld dword[esp+4]
!fld dword[esp]
!fcomi st1
!fcmovb st1
EndProcedure
CompilerElse
Procedure.f MinF(n1.f, n2.f)
If n1<n2
ProcedureReturn n1
EndIf
ProcedureReturn n2
EndProcedure
Procedure.f MaxF(n1.f, n2.f)
If n1>n2
ProcedureReturn n1
EndIf
ProcedureReturn n2
EndProcedure
CompilerEndIf
Structure COLOUR
r.f
g.f
b.f
EndStructure
Structure HSV
h.f
s.f
v.f
EndStructure
;
; Calculate HSV from RGB
; R,G,B are all values between 0 and 1 for intensity of colour
; Hue is in degrees
; Lightness is betweeen 0 And 1
; Saturation is between 0 And 1
Procedure RGB2HSV(*c1.COLOUR, *hsv.HSV)
DefType.f themin,themax,delta
themin = MinF(*c1\r,MinF(*c1\g,*c1\b))
themax = MaxF(*c1\r,MaxF(*c1\g,*c1\b))
delta = themax - themin
Debug themax
Debug themin
Debug delta
*hsv\v = themax
*hsv\s = 0
If themax > 0
*hsv\s = delta / themax
EndIf
*hsv\h = 0
If delta > 0
If themax=*c1\r And themax<>*c1\g
*hsv\h = *hsv\h + ((*c1\g - *c1\b) / delta)
EndIf
If themax=*c1\g And themax<>*c1\b
*hsv\h = *hsv\h + (2 + (*c1\b - *c1\r) / delta)
EndIf
If themax=*c1\b And themax<>*c1\r
*hsv\h = *hsv\h + (4 + (*c1\r - *c1\g) / delta)
EndIf
*hsv\h = *hsv\h * 60
EndIf
EndProcedure
; Small demo
DefType.COLOUR rgb
DefType.HSV hsv
rgb\r = 1 : rgb\g = 0 : rgb\b = 0
RGB2HSV(@rgb, @hsv)
Debug StrF(hsv\h)+", "+StrF(hsv\s)+", "+StrF(hsv\v)
End