Na da wirst Du wohl Probleme bekommen, weil die Excel-Tabelle nicht mehr als
255 Spalten hat. Also ein größeres Bild als 255 Pixel breite ist nicht ;)
Das geht generell so, dass Du zunächst ein Bild lädst und das Zeile für Zeile
ausliest.
Private Declare Function CreateCompatibleDC Lib "gdi32" ( _
Byval hDC As Long) As Long
Private Declare Function SelectObject Lib "gdi32" ( _
Byval hDC As Long, _
Byval hObject As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" ( _
Byval hDC As Long) As Long
Private Declare Function GetPixel Lib "gdi32" ( _
Byval hDC As Long, _
Byval x As Long, _
Byval y AS Long) As Long
Private Sub MapPixel(Byval sFileName As String, Byval sTableName As String)
Dim st As StdPicture
Dim hMemDC As Long,
Dim x As Long, y As Long
Dim n As Long
Set st = LoadPicture(sFileName)
hMemDC = CreateCompatibleDC(0)
SelectObject hMemDC, st.Handle
For y = 0 To st.Height \ 16
For x = 0 To st.Width \ 16
n = GetPixel(hMemDC, x, y)
IF n -1 Then
ActiveWorkbook.Sheets(sTableName).Cells(y+1, x+1).Value = n
End IF
Next x, y
DeleteDC hMemDC
End Sub
Man kann sich das Bild auch wieder zusammenbasteln:
ersetzen:
If n - 1 Then
ActiveWorkbook.Sheets(sTableName).Cells(y+1, x+1).Select
With Selection.Interior
.Color = n
.Pattern = xlSolid
End With
End If
geschrieben von
Lordchen
,
22.09.2005, 15:46 Uhr
, 64 mal gelesen