1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61:
| var H1, S1, L1: Single; RGB1: TColor; matrix: array[0..640] of array[0..480] of array[1..5] of Single;
procedure TForm1.RBG_to_HLSClick(Sender: TObject); type TRGBColor = record R, G, B: Byte; end; var pData: ^TRGBColor; x, y : Integer; EC1HMin, EC1HMax, EC1SMin, EC1SMax, EC1LMin, EC1LMax, EC2HMin, EC2HMax, EC2SMin, EC2SMax, EC2LMin, EC2LMax: Single; begin ECI1HMin := StrToFloat(FParam.EC1HMin.Text); ECI1HMax := StrToFloat(FParam.EC1HMax.Text); ECI1SMin := StrToFloat(FParam.EC1SMin.Text); ECI1SMax := StrToFloat(FParam.EC1SMax.Text); ECI1LMin := StrToFloat(FParam.EC1LMin.Text); ECI1LMax := StrToFloat(FParam.EC1LMax.Text); ECI2HMin := StrToFloat(FParam.EC2HMin.Text); ECI2HMax := StrToFloat(FParam.EC2HMax.Text); ECI2SMin := StrToFloat(FParam.EC2SMin.Text); ECI2SMax := StrToFloat(FParam.EC2SMax.Text); ECI2LMin := StrToFloat(FParam.EC2LMin.Text); ECI2LMax := StrToFloat(FParam.EC2LMax.Text); FBitmap.PixelFormat := pf24Bit; for y := 0 to FBitmap.Height - 1 do begin pData := FBitmap.ScanLine[y]; for x := 0 to FBitmap.Width - 1 do begin RGB1 := (pData^.R)*256*256 + (pData^.G)*256 + (pData^.B); RGBtoHSL(RGB1, H1, S1, L1); matrix[x, y, 1]:= H1; matrix[x, y, 2]:= S1; matrix[x, y, 3]:= L1; inc(pData); if (matrix[x, y, 1] > EC1HMin) and (matrix[x, y, 1] < EC1HMax) and (matrix[x, y, 2] > EC1SMin) and (matrix[x, y, 2] < EC1SMax) and (matrix[x, y, 3] > EC1LMin) and (matrix[x, y, 3] < EC1LMax) then matrix[x, y, 4] := 1 else matrix[x, y, 4] := 0; if (matrix[x, y, 1] > EC2HMin) and (matrix[x, y, 1] < EC2HMax) and (matrix[x, y, 2] > EC2SMin) and (matrix[x, y, 2] < EC2SMax) and (matrix[x, y, 3] > EC2LMin) and (matrix[x, y, 3] < EC2LMax) then matrix[x, y, 5] := 1 else matrix[x, y, 5] := 0; end; end; end; |