Hallo Paulix,
hier mal der erste Teil:
Private Const COLORONCOLOR = 3
Private Const HALFTONE = 4
Public Sub PrintPicture(Path As String)
Dim TmpPic As StdPicture, Fkt1#, Fkt2#
Dim QuellBreite&, QuellHoehe&, ZielBreite&, ZielHoehe&
Dim P1hdc&, P1OldHandle&, SW1&, SH1&
Dim P2hdc&, P2OldHandle&, OldMode&
If Dir$(Path) = "" Then
MsgBox "Datei nicht gefunden:" & vbCr & Path, vbExclamation + vbOKOnly
Exit Sub
End If
Screen.MousePointer = vbHourglass
DoEvents
Set TmpPic = LoadPicture(Path)
QuellBreite = Int(0.5 + Me.ScaleX(TmpPic.Width, vbHimetric, vbPixels))
QuellHoehe = Int(0.5 + Me.ScaleY(TmpPic.Height, vbHimetric, vbPixels))
P2hdc = CreateCompatibleDC(0)
P2OldHandle = SelectObject(P2hdc, TmpPic.Handle)
SW1 = 2000
SH1 = 2000
Fkt1 = SW1 / QuellBreite
Fkt2 = SH1 / QuellHoehe
If Fkt2 < Fkt1 Then Fkt1 = Fkt2
If Fkt1 > 1 Then Fkt1 = 1
SW1 = QuellBreite * Fkt1
SH1 = QuellHoehe * Fkt1
P1hdc = CreateCompatibleDC(0)
P1OldHandle = SelectObject(P1hdc, _
CreateCompatibleBitmap(Me.hdc, SW1, SH1))
OldMode = SetStretchBltMode(P1hdc, HALFTONE)
Call StretchBlt(P1hdc, 0, 0, SW1, SH1, _
P2hdc, 0, 0, QuellBreite, QuellHoehe, vbSrcCopy)
Call SetStretchBltMode(P1hdc, OldMode)
Call SelectObject(P2hdc, P2OldHandle)
Set TmpPic = LoadPicture()
Call DeleteDC(P2hdc)
With Printer
If SW1 > SH1 Then
.Orientation = vbPRORLandscape
Else
.Orientation = vbPRORPortrait
End If
.ScaleMode = vbPixels
Printer.Print " "
Fkt1 = .ScaleWidth / SW1
Fkt2 = .ScaleHeight / SH1
If Fkt2 < Fkt1 Then Fkt1 = Fkt2
ZielBreite = SW1 * Fkt1
ZielHoehe = SH1 * Fkt1
OldMode = SetStretchBltMode(.hdc, COLORONCOLOR)
Call StretchBlt(.hdc, (.ScaleWidth - ZielBreite) / 2, _
(.ScaleHeight - ZielHoehe) / 2, ZielBreite, ZielHoehe, _
P1hdc, 0, 0, SW1, SH1, vbSrcCopy)
Call SetStretchBltMode(.hdc, OldMode)
.EndDoc
End With
Call DeleteObject(SelectObject(P1hdc, P1OldHandle))
Call DeleteDC(P1hdc)
Screen.MousePointer = vbDefault
End Sub Wie gross sind denn deine Bilder in Pixeln?
Gruss,
Zardoz |