
Originally Posted by
IliaPreston
Any response to my post #28 would be greatly appreciated.
...
I need to make the thumbnail show center-justified and be the correct size (fit the picturebox).
I don't know how to do that.
The cGDIPlusCache.DrawImage method has additional (optional x, y, ...) Params to offer.
IMO you need to play around more with IntelliSense.
(I often just "type an extra space" in between Params for a fast lookup of a Method-Defs ParamList).
And as for "how to calculate centered Offsets".
I think you're programming long enough, to have seen this "halfed-difference" thing a few times:
x = (ContainerObj.Width - ObjToCenter.Width) / 2 'same for y-Offsets with the Heights
Here's the caching-code again, which now does that...
Code:
Option Explicit
Private GC As New cGDIPlusCache
Private Sub Form_Click()
CacheAndRenderThumb "c:\temp\test.avi", Thumbnail_P_B
End Sub
Private Sub CacheAndRenderThumb(FileName As String, PB As PictureBox)
PB.AutoRedraw = True
PB.Cls
PB.ScaleMode = vbPixels
Dim Key As String, x As Long, y As Long
Key = Mid$(FileName, InStrRev(FileName, "\") + 1)
If Not GC.Exists(Key) Then GC.AddFromShell Key, FileName, PB.ScaleWidth
x = (PB.ScaleWidth - GC.Width(Key)) / 2
y = (PB.ScaleHeight - GC.Height(Key)) / 2
GC.DrawImage PB.hDC, Key, x, y
PB.Refresh
End Sub
Olaf