精華區beta Programming 關於我們 聯絡資訊
> 力天神 撰寫於文章 <3SQi8U$m10@bbs.cs.nthu.edu.tw>... > 請問要怎樣把讀取的圖形檔色階轉成三原色??? '測試本範例請於表單布置 Label1,2,3、Picture1 Option Explicit Private Const cst_REDCOLOR As Byte = 0 Private Const cst_GREENCOLOR As Byte = 1 Private Const cst_BLUECOLOR As Byte = 2 Private Sub Form_Load() With Picture1 .AutoSize = True .Picture = LoadPicture("d:\image\01.jpg") End With End Sub Private Function SeperateRGBColor(ByVal LongColor As Long) As Variant Dim RGBArray(2) As Byte RGBArray(cst_REDCOLOR) = LongColor Mod 256 LongColor = LongColor / 256 RGBArray(cst_GREENCOLOR) = LongColor Mod 256 LongColor = LongColor / 256 RGBArray(cst_BLUECOLOR) = LongColor Mod 256 SeperateRGBColor = RGBArray End Function Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim ColorValue As Long Dim AcceptArray As Variant ColorValue = Picture1.Point(X, Y) '執行 RGB 值之換算函數 AcceptArray = SeperateRGBColor(ColorValue) Label1.Caption = "RED:" & AcceptArray(cst_REDCOLOR) Label2.Caption = "GREEN:" & AcceptArray(cst_GREENCOLOR) Label3.Caption = "BLUE:" & AcceptArray(cst_BLUECOLOR) End Sub