Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need for thumbnails

7 views
Skip to first unread message

k_zeon

unread,
Nov 12, 2009, 4:33:06 PM11/12/09
to
Hi

I have made a small a program that lists jpg picture files ie app.path &
"\testfolder\Image1.jpg" in a grid 2,3,4 etc etc
I need to use a Listview to show thumbnails of each picture. (or if there is
a free alternative would be interested)
At present i am using GDI+ to resize pics on the fly and load them into an
Imagelist
I can then assign them to the Listview and display them.

As a test i tried loading 500 images and I get an error. 'Out of Memory'.
the max i can load is 350 with out any error.

So what i have now decieded is to show 50 or 100 at a time.

I am struggling on how to do this.

Below is the code I have now. (not very good i'm afraid) just for testing i
am using 3 images at a time.

Any help would be great

Thanks in advance.

Private Sub Command3_Click()
If DontGoForward = True Then Exit Sub ' this is set when i reach the end


Dim Token As Long


If PicsLoading = True Then
PicsLoading = False
EndImageNumber = 2
Else

StartImageNumber = EndImageNumber + 1
EndImageNumber = EndImageNumber + 3
If StartImageNumber <= List1.ListCount - 1 Then

Else
Exit Sub
End If
End If


lblstart.Caption = StartImageNumber
lblend.Caption = EndImageNumber


' Clear the controls
Set ListView1.Icons = Nothing
ListView1.ListItems.Clear
ImageList1.ListImages.Clear

' Initialise GDI+
Token = InitGDIPlus

Dim X As Integer
If EndImageNumber > List1.ListCount - 1 Then
EndImageNumber = List1.ListCount - 1
DontGoForward = True
End If
For X = StartImageNumber To EndImageNumber

Call AddPic(List1.List(X), "Movie 1") '<<<< this just calls a sub to
resize pic and place in imagelist for listview to use.

Next X

' Free GDI+
FreeGDIPlus Token

ListView1.Arrange = lvwAutoTop
ListView1.Refresh


End Sub

duke

unread,
Nov 12, 2009, 11:23:10 PM11/12/09
to

I have created a "Photo Book" program that accomplishes what you are
attempting, except I simply use an array of image controls. instead of
using Listview. The program has become very elaborate and would be
impossible for me to post sections of it and still make sense for
someone to follow, besides some may criticize my programming
techniques as being unorthodoxed but it works for me.
I have been able to display over 600 images on my Benq monitor that
has a 1280 X 1024 resolution and over 800 thumbnails on my son's 24
inch monitor without any problems.

I therefore offer some very general suggestions that I used:

I prefer to use the image control for this purpose as it is extremely
simple to resize the thumbnails to whatever I want with the "stretch"
property.
Assuming you are displaying pictures from a digital camera, you are
aware that all digital cameras ( all that I have worked with ) are
have EXIF headers which have all pertinent information about the
picture and embed a thumbnail usually 160 X 120 which can be
extracted, and loaded into in your listview, or I use it to load my
image control array.

I hope I have offered you some food for thought...... Best of Luck.

Duke

k_zeon

unread,
Nov 14, 2009, 12:56:00 PM11/14/09
to
Hi Duke

I have just finished making my own usercontrol to display a picture (aprox
inch & half wide and 2inch high.
I can load them up now no problem, except one.

the Picturebox that i use to display the usercontrol has a maximum height of
245745 so when i show more pics they dont get shown at the bottom.
I use a scollbar to scroll down and then get the the limit that the picture
box gets to.

I am there fore back to the problem I had before of showing say 100 at a
time and having a Back & Forward button.

I will have another go at coding this. ie Click forward and the next 100
gets shown and vice versa.

I got stuck when i reach the end and the count does not reach the 100 mark.
ie it gets to say 63.
Now when I click the back button I want to go back the 63 first and then 100
thereafter

any snippet of code that could help would be much appreciated.

thanks


Garry

"duke" <nos...@3web.net> wrote in message
news:6a150fff-ef37-455d...@s31g2000yqs.googlegroups.com...

Larry Serflaten

unread,
Nov 14, 2009, 4:39:27 PM11/14/09
to

"k_zeon" <silverm...@googlemail.com> wrote

> any snippet of code that could help would be much appreciated.

Here is a rough cut of a thumbnail viewer. Its rough in that extracting
the thumbnail is not optimized and it takes over the CPU when it needs
to load images. It could be improved by using a timer to control the
loading of images such that they load even while the user isn't doing
anything. As it is, the images only load if they are needed for display.
Because of that, every time you go to a page that you haven't been to
before, the images have to load and will hog the CPU until the page
is filled. You should be aware, if your pictures are large files, just
loading them into memory is going to take some amount of time
due to disk access delays.

But this is an example of how you can store your thumbnails in an
array such that you only store the thumbnail image. I've tested it
to over 1000 images and it still had room for more.

Have a look, use as you see fit.....

To a new form, add a FileListBox, a Picturebox, and a Vertical
ScrollBar. (For ease of use I use a hidden FileListBox to get the
file names) Paste in the code below and change the AddPath call
to a valid folder on your system.

To load up the array quickly, maximize the form, and step down a
page at a time. When you get to the bottom, the array will be filled
and you can then see how it adjusts to resizing and such.

Have fun!
LFS

Option Explicit
Private Type ThumbNails
Image As StdPicture
Name As String
End Type

Private THM() As ThumbNails
Private Dummy As StdPicture
Private TopIndex As Long
Private ListCount As Long
Private ShowCols As Long
Private ShowRows As Long

Private Sub Form_Load()
InitializeForm
' Add one or more paths to be displayed
AddPath 'USE A VALID FOLDER NAME HERE'
End Sub

Private Sub Form_Paint()
UpdateThumbs
End Sub

Private Sub VScroll1_Change()
TopIndex = VScroll1.Value * ShowCols
UpdateThumbs
End Sub

Private Sub VScroll1_GotFocus()
File1.SetFocus
End Sub

Private Sub Form_Resize()
Dim cols&, rows As Long
Dim stepX As Long, stepY As Long
' Adjust scroll bar to right edge of form
VScroll1.Move ScaleWidth - 240, 0, 240, ScaleHeight
' Calculate number of cols and rows
stepX = Picture1.Width + 30
stepY = Picture1.Height + 30
cols = (ScaleWidth - VScroll1.Width) \ stepX
rows = ScaleHeight \ stepY
' Only update if values have changed
If (cols <> ShowCols) Or (rows <> ShowRows) Then
If (cols > 0) And (rows > 0) Then
ShowCols = cols
ShowRows = rows
Cls
UpdateThumbs
End If
End If
End Sub


' - - - - - - - - -
Sub AddPath(Path As String)
Dim idx As Long, file As Long
' Add \ if missing
If Right$(Path, 1) Like "[!/\]" Then
Path = Path & "\"
End If
' List files
File1.Path = Path
File1.Refresh
' Increase array if needed
If UBound(THM) < (ListCount + File1.ListCount) Then
ReDim Preserve THM(ListCount + File1.ListCount)
End If
' Store filenames (no images yet)
idx = ListCount
For file = 0 To File1.ListCount - 1
THM(idx).Name = Path & File1.List(idx)
idx = idx + 1
Next
ListCount = idx
Caption = "Total: " & CStr(ListCount)
End Sub

Private Sub InitializeForm()
' Initialize form and controls
File1.Pattern = "*.bmp;*.jpg;*.gif"
File1.Move -2000, 0, 1000, 6000
Picture1.BorderStyle = vbBSNone
Picture1.Move 0, 0, 1200, 1200 ' Thumbnail size
Picture1.AutoRedraw = True
Picture1.BackColor = &HEEEEEE
Picture1.Line (0, 0)-Step(Picture1.ScaleWidth, Picture1.ScaleHeight), &HCCCCCC, B
Picture1.Line (-15, -15)-Step(Picture1.ScaleWidth, Picture1.ScaleHeight), &HCCCCCC, B
Picture1.Visible = False
Picture1.ScaleMode = vbPixels
Set Dummy = Picture1.Image
VScroll1.Move ScaleWidth - 240, 0, 240, ScaleHeight
VScroll1.Min = 0
VScroll1.Max = 1
VScroll1.SmallChange = 1
Me.BackColor = vbWhite
' Start with some space in the array
ReDim THM(0 To 100)
End Sub

Private Sub UpdateThumbs()
Dim idx&, X&, Y As Long
Dim stepX As Long, stepY As Long
Dim ready As Boolean
' Draw thumbs to form
stepX = Picture1.Width + 30
stepY = Picture1.Height + 30
idx = TopIndex
For Y = 0 To ShowRows - 1
ready = True
For X = 0 To ShowCols - 1
If idx < ListCount Then
If THM(idx).Image Is Nothing Then
' If not loaded yet, show dummy and clear ready
PaintPicture Dummy, X * stepX + 15, Y * stepY + 15
ready = False
Else
' Image is stored in the array
PaintPicture THM(idx).Image, X * stepX + 15, Y * stepY + 15
End If
Else
' When list ends in the middle of a row, draw the background
Line (X * stepX + 15, Y * stepY + 15)-Step(stepX - 30, stepY - 30), BackColor, BF
End If
idx = idx + 1
Next X
' If loading is needed, load the row and do it over
If Not ready Then
LoadRow idx - ShowCols
idx = idx - ShowCols
Y = Y - 1
End If
Next Y
' Adjust scroll bar physics
VScroll1.Max = (ListCount \ ShowCols) - ShowRows + 1
If VScroll1.Max < 1 Then
VScroll1.Max = 0
VScroll1.LargeChange = 1
Else
If ShowRows > 1 Then
VScroll1.LargeChange = ShowRows - 1
Else
VScroll1.LargeChange = 1
End If
End If
End Sub

Sub LoadRow(ByVal StartIndex As Long)
Dim EndIndex As Long
' Calculate array indexes
EndIndex = StartIndex + ShowCols
If EndIndex > ListCount Then
EndIndex = ListCount
End If
' Load next row
While StartIndex < EndIndex
BuildThumb StartIndex
StartIndex = StartIndex + 1
Wend
End Sub

Sub BuildThumb(Index As Long)
Dim pic As StdPicture
Dim asp As Single, siz As Single
' Load file
Set pic = LoadPicture(THM(Index).Name)
' Calculate aspect
asp = pic.Height / pic.Width
With Picture1
' Start fresh...
Set .Picture = Nothing
If asp >= 1 Then
' Image is tall
siz = .ScaleWidth / asp
pic.Render .hDC, (.ScaleWidth - siz) / 2, .ScaleHeight, siz, -.ScaleHeight, 0, 0, pic.Width, pic.Height, 0
Else
' Image is wide
siz = .ScaleHeight * asp
pic.Render .hDC, 0, .ScaleHeight - (.ScaleHeight - siz) / 2, .ScaleWidth, -siz, 0, 0, pic.Width, pic.Height, 0
End If
End With
' Store thumbnail
Set THM(Index).Image = Picture1.Image
End Sub

Nobody

unread,
Nov 14, 2009, 6:03:35 PM11/14/09
to
"Larry Serflaten" <serf...@usinternet.com> wrote in message
news:e8XuQtXZ...@TK2MSFTNGP04.phx.gbl...

Off topic: Please check your system time and time zone. It seems to be one
hour off.


Larry Serflaten

unread,
Nov 14, 2009, 5:05:20 PM11/14/09
to

"k_zeon" <silverm...@googlemail.com> wrote

> I have just finished making my own usercontrol to display a picture (aprox
> inch & half wide and 2inch high.
> I can load them up now no problem, except one.

I just tried using a large thumbnail image (3500, 3500 twips) and found
the array method also ran out of memory. For testing the 1000 images,
I used the small thumbnail, as shown in the example code (1200, 1200).

Another caveate I found, the BuildThumb does the aspect calculation
with the assumption that the target area is square. Setting it to other than
square (as you indicate above) distorts the image. Additional calculation
would be needed to account for each dimension.

While I would still advise using a timer to load images in the background,
you might want to only keep 3 pages of images in memory, the previous
page, the current page, and the next page. That is sort of a windowing
method in that you're looking at the files through a moving window of
loaded images.

But, keep at it, and be creative! If you find a good solution, do post
back to tell others about it....

LFS

k_zeon

unread,
Nov 14, 2009, 6:38:13 PM11/14/09
to
Hi Guys

Just thought I would post some info on where i am at.

I have created a usercontrol that allows me to add an image and also change
the border colour and back colour.I can also enter the name of the file and
also the path to the picture.
I have then been able to load this usercontrol and place in a picturebox.
Once i have 50 loaded i call a resize event to arrange on my Picturebox.(
each pic will be loaded from a list)
When getting the picture , I have found a Module that uses GDI+ to resize an
image on the fly keeping the aspect ratio and I can resize to whatever I
need.

(I did try to load 500 but it seems that the Picturebox has a limitation of
how high it can be, so once i go above a certain amount i cannot scroll down
any further) ie Pic1.Height + Pic2.Height + Pic3.Height etc etc = How High
PictureBox needs to be.
I have found another usercontrol created by someone else that is a
Scrollport ie i just place my PictureBox onto this usercontrol and it deals
with all the scrollbar stuff.

As i said above i load 50 pics at a time. I can resize my form and the
pictures move to the correct X Y positions. This is as far as I have got and
all seems to work well.

What I am now trying to do is Load my form with 50 pics and then have 2
buttons on the form for Backwards & Forwards.

Maybe I am just tired but for the life of me cannot think of the best way to
code for Backwards & Forwards. <<< If anyone can help, pls email me. (tks)

Below is some code I use to load the first 50, this is done in a Button
Click event for test purposes but will be moved once I add to my main
projects.

If anyone is interested in what I have so far , then let me know and I would
be happy to email.

Private Sub Command1_Click()

Dim picwidth As Integer
Dim picheight As Integer
Dim xx As Long
Dim y As Long
Dim lCols As Long
Dim Token As Long


' Initialise GDI+
Token = InitGDIPlus

LockWindow Picture1.hWnd, True
Dim x As Integer

'If any controls are loaded unload them
For x = 1 To UserControl11.Count - 1
Unload UserControl11(x)
Next x
UserControl11(0).Visible = False ' Set origonal one to invisible

For x = 0 To 55
DoEvents
Label1.Caption = x
If x > 0 Then

Load UserControl11(x)
End If
UserControl11(x).Height = 3735
UserControl11(x).Width = 2895

picwidth = UserControl11(x).Width + 200
picheight = UserControl11(x).Height + 200
lCols = Int((Picture1.ScaleWidth) / picwidth)

xx = (x Mod lCols) * picwidth
y = Int(x / lCols) * picheight

UserControl11(x).Move xx + 200, y + 200
Picture1.Height = y + UserControl11(0).Height + 400

UserControl11(x).MovieName = "Test Movie"
UserControl11(x).MoviePicturePath = "Testpath"
UserControl11(x).MovieID = x
UserControl11(x).MoviePicture =
modGDIPlusResize.LoadPictureGDIPlus("C:\Documents and
Settings\Garry\Desktop\testttt\test2\Largeimage.jpg", 200, 200, , True) '<<
This is the GDI+ mod call to resize picture
UserControl11(x).Visible = True
Next x


' Free GDI+
FreeGDIPlus Token
LockWindow Picture1.hWnd, False

ScrollingViewPort1.FormatControl '<< this will force the usercontrol to
arrange my Pictures


End Sub

"Larry Serflaten" <serf...@usinternet.com> wrote in message

news:eGiHu7XZ...@TK2MSFTNGP04.phx.gbl...

Nobody

unread,
Nov 14, 2009, 9:32:17 PM11/14/09
to
Here are two functions GetPictureBits/SetPictureBits that take a hDC of an
AutoRedraw PictureBox, and returns the picture as byte array(no resizing),
or restore back from a byte array. This is for caching thumbnails. Speed
tests show that it takes 86us to get the picture as byte array, and 45us to
restore byte array to a picture box. These times are for 128x128 pixels
picture box(client area), and for Intel Quad 2.4 GHz, XP+SP2+4GB memory,
1280x1024x32Bit color display. Buffer size needed is 66KB per picture.

To try the sample, add a PictureBox and Command button to Form1, then use
the following code:

' Form1 code ============================

Option Explicit

Private Sub Command1_Click()
Dim bOut() As Byte
Dim LastDllError As Long
Dim ret As Long

' Set PictureBox size to 132x132, client area would
' be 128x128. 2 Pixels at either side are used for border.
Picture1.Width = 132 * Screen.TwipsPerPixelX
Picture1.Height = 132 * Screen.TwipsPerPixelY

Picture1.AutoRedraw = True

' Draw a "\" line
Picture1.Line (0, 0)-(500, 500)
ret = GetPictureBits(Picture1.hDC, bOut(), LastDllError)
Debug.Print "GetPictureBits returned " & ret & _
", LastDllError = " & LastDllError

' Draw a "/" line, this will be erased by the call to SetPictureBits()
Picture1.Line (500, 0)-(0, 500)
MsgBox "About to restore PictureBox"
If ret = 0 Then
ret = SetPictureBits(Picture1.hDC, bOut(), LastDllError)
Debug.Print "SetPictureBits returned " & ret & _
", LastDllError = " & LastDllError
Picture1.Refresh
End If
End Sub

' Module1 code ============================

Option Explicit

Public Type RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type
Public Type BITMAP '14 bytes
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
Public Type BITMAPINFOHEADER '40 bytes
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Public Type BITMAPINFO
bmiHeader As BITMAPINFOHEADER
bmiColors(0 To 255) As RGBQUAD
End Type
Public Const BI_RGB = 0&
Public Const BI_RLE4 = 2&
Public Const BI_RLE8 = 1&
Public Const DIB_RGB_COLORS = 0 ' color table in RGBs
Public Const DIB_PAL_COLORS = 1 ' color table in palette indices
Public Declare Function GetDIBits Lib "gdi32" (ByVal hDC As Long, _
ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As _
Long, lpBits As Any, lpbi As BITMAPINFO, ByVal wUsage As Long) As Long
Public Declare Function SetDIBits Lib "gdi32" (ByVal hDC As Long, _
ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As _
Long, lpBits As Any, lpbi As BITMAPINFO, ByVal wUsage As Long) As Long
Public Const OBJ_BITMAP = 7
Public Const OBJ_BRUSH = 2
Public Const OBJ_FONT = 6
Public Const OBJ_PAL = 5
Public Const OBJ_PEN = 1
Public Declare Function GetCurrentObject Lib "gdi32" (ByVal hDC As Long, _
ByVal uObjectType As Long) As Long
Public Declare Function GetObject Lib "gdi32" Alias "GetObjectA" ( _
ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
Destination As Any, Source As Any, ByVal Length As Long)
Public Declare Sub OutputDebugString Lib "kernel32" Alias _
"OutputDebugStringA" (ByVal lpOutputString As String)

'
' GetPictureBits
'
' Gets bitmap info and pixel value of AutoRedraw PictureBox or form
'
' PARAMETERS
'
' hDC hDC of AutoRedraw PictureBox or form
' bOut Receives bitmap info and pixel value. The routine ReDim
' this array to the correct size
' LastDllError LastDllError when an error occurs
'
' RETURNS
'
' 0 Success
' -1 GetCurrentObject failed
' -2 GetObject failed
' -3 Out of memory
' -4 GetDIBits failed
' -5 Unknown error
'
Public Function GetPictureBits(ByVal hDC As Long, ByRef bOut() As Byte, _
ByRef LastDllError As Long) As Long
Dim ResumeNext As Boolean
Dim ErrNumber As Long
Dim hBitmap As Long
Dim bm As BITMAP
Dim bi As BITMAPINFO
Dim BufferSize As Long
Dim ret As Long

On Error GoTo ErrorHandler

' Get the handle to the current bitmap
hBitmap = GetCurrentObject(hDC, OBJ_BITMAP)
If hBitmap = 0 Then
LastDllError = Err.LastDllError
GetPictureBits = -1 ' GetCurrentObject failed
Exit Function
End If

' Debug.Print "hBitmap = " & Hex(hBitmap)

' Get bitmap info, like width and height
If GetObject(hBitmap, Len(bm), bm) = 0 Then
LastDllError = Err.LastDllError
GetPictureBits = -2 ' GetObject failed
Exit Function
End If

' Buffer size to hold pixel data
BufferSize = ((((bm.bmWidth * bm.bmBitsPixel) + 31) And &HFFFFFFE0) _
\ 8) * bm.bmHeight
' We also need to include BITMAPINFO. We choose to include
' it at the beginning.
BufferSize = BufferSize + Len(bi)

' Allocate buffer
ResumeNext = True
ReDim bOut(0 To BufferSize - 1) As Byte
ResumeNext = False
If ErrNumber <> 0 Then
LastDllError = 0
GetPictureBits = -3 ' Out of memory
Exit Function
End If

bi.bmiHeader.biSize = LenB(bi.bmiHeader)
bi.bmiHeader.biWidth = bm.bmWidth
bi.bmiHeader.biHeight = bm.bmHeight
bi.bmiHeader.biPlanes = bm.bmPlanes
bi.bmiHeader.biBitCount = bm.bmBitsPixel
bi.bmiHeader.biCompression = BI_RGB
bi.bmiHeader.biSizeImage = 0
bi.bmiHeader.biXPelsPerMeter = 0
bi.bmiHeader.biYPelsPerMeter = 0
bi.bmiHeader.biClrUsed = 0
bi.bmiHeader.biClrImportant = 0

ret = GetDIBits(hDC, hBitmap, 0, bm.bmHeight, bOut(Len(bi)), bi, _
DIB_RGB_COLORS)
If ret = 0 Then
LastDllError = Err.LastDllError
GetPictureBits = -4 ' GetDIBits failed
Exit Function
End If

' Copy BITMAPINFO to the beginning of the array
CopyMemory bOut(0), bi, Len(bi)

GetPictureBits = 0 ' Success

ExitSub:
Exit Function
ErrorHandler:
ErrNumber = Err.Number
If ResumeNext Then
Resume Next
Else
LastDllError = Err.LastDllError
GetPictureBits = -5 ' Unknown error
'MsgBox "GetPictureBits: Error " & Err.Number & ": " & _
Err.Description
Resume ExitSub
End If
End Function

'
' SetPictureBits
'
' Restores bitmap info and pixel value to AutoRedraw PictureBox or form
'
' PARAMETERS
'
' hDC hDC of AutoRedraw PictureBox or form
' bOut Array of bitmap info and pixel values, from
' GetPictureBits routine
' LastDllError LastDllError when an error occurs
'
' RETURNS
'
' 0 Success
' -1 GetCurrentObject failed
' -2 GetObject failed
' -3 GetDIBits failed
' -4 Unknown error
'
Public Function SetPictureBits(ByVal hDC As Long, ByRef bOut() As Byte, _
ByRef LastDllError As Long) As Long
Dim ResumeNext As Boolean
Dim ErrNumber As Long
Dim hBitmap As Long
Dim bm As BITMAP
Dim bi As BITMAPINFO
Dim BufferSize As Long
Dim ret As Long

On Error GoTo ErrorHandler

' Get the handle to the current bitmap
hBitmap = GetCurrentObject(hDC, OBJ_BITMAP)
If hBitmap = 0 Then
LastDllError = Err.LastDllError
SetPictureBits = -1 ' GetCurrentObject failed
Exit Function
End If

' Debug.Print "hBitmap = " & Hex(hBitmap)

' Get bitmap info, like width and height
If GetObject(hBitmap, Len(bm), bm) = 0 Then
LastDllError = Err.LastDllError
SetPictureBits = -2 ' GetObject failed
Exit Function
End If


' Buffer size to hold pixel data
BufferSize = ((((bm.bmWidth * bm.bmBitsPixel) + 31) And &HFFFFFFE0) _
\ 8) * bm.bmHeight
' We also need to include BITMAPINFO. We choose to include
' it at the beginning.
BufferSize = BufferSize + Len(bi)

' Copy BITMAPINFO from the beginning of the array
CopyMemory bi, bOut(0), Len(bi)
ret = SetDIBits(hDC, hBitmap, 0, bm.bmHeight, bOut(Len(bi)), bi, _
DIB_RGB_COLORS)
If ret = 0 Then
LastDllError = Err.LastDllError
SetPictureBits = -3 ' SetDIBits failed
Exit Function
End If

SetPictureBits = 0 ' Success

ExitSub:
Exit Function
ErrorHandler:
ErrNumber = Err.Number
If ResumeNext Then
Resume Next
Else
LastDllError = Err.LastDllError
SetPictureBits = -4 ' Unknown error
'MsgBox "SetPictureBits: Error " & Err.Number & ": " & _
Err.Description
Resume ExitSub
End If
End Function

Public Sub DebugPrint(ByRef MSG As String)
Debug.Print MSG
OutputDebugString MSG & vbCrLf
End Sub

Larry Serflaten

unread,
Nov 14, 2009, 9:10:25 PM11/14/09
to

"Nobody" <nob...@nobody.com> wrote
> "Larry Serflaten" <serf...@usinternet.com> wrote

> Off topic: Please check your system time and time zone. It seems to be one
> hour off.

Interesting. I see nothing wrong here. I am within seconds of www.time.gov
with the appropeate time zone correctly selected.

posted at 21:10 hours
LFS


Larry Serflaten

unread,
Nov 14, 2009, 9:30:04 PM11/14/09
to

"k_zeon" <silverm...@googlemail.com> wrote

> Maybe I am just tired but for the life of me cannot think of the best way to
> code for Backwards & Forwards. <<< If anyone can help, pls email me. (tks)

> UserControl11(x).MoviePicture =


> modGDIPlusResize.LoadPictureGDIPlus("C:\Documents and
> Settings\Garry\Desktop\testttt\test2\Largeimage.jpg", 200, 200, , True) '<<
> This is the GDI+ mod call to resize picture

> ScrollingViewPort1.FormatControl '<< this will force the usercontrol to
> arrange my Pictures


From the code you posted it is apparent you are only showing one picture.
Somehow you have to turn that into a list of pictures based on the For/Next
loop iteration. Typically Foward and Back are routines that apply to
the list index value used to denote the first image on the page. Build the
example I posted earlier and check out how TopIndex is used. That
is the value that the scroll bar adjusts, and it is the value used in
UpdateThumbs to indicate where (in the array) to start.

If you're lucky, your ViewPort will expose methods to scroll the list
from code. Check and see....

HTH
LFS


Larry Serflaten

unread,
Nov 14, 2009, 9:39:21 PM11/14/09
to

"Larry Serflaten" <serf...@usinternet.com> wrote
> > Off topic: Please check your system time and time zone. It seems to be one
> > hour off.
>
> Interesting. I see nothing wrong here. I am within seconds of www.time.gov
> with the appropeate time zone correctly selected.
>
> posted at 21:10 hours

Which seems to agree with an outside observer:
http://groups.google.com/group/microsoft.public.vb.general.discussion/msg/a94b31384ee7d61b?hl=en

Shows I posted at 9:10, just as my clock was indicating.

Do you still think its off?

LFS


Nobody

unread,
Nov 14, 2009, 10:45:00 PM11/14/09
to
"Larry Serflaten" <serf...@usinternet.com> wrote in message
news:OzN6pEaZ...@TK2MSFTNGP04.phx.gbl...

Seen at 22:10 hours ET, but shows 21:10 hours ET. Must be your newsserver.
Your posts seems to go into time warp and appear in the past(they get
inserted in the middle). I am using MS newsserver.


Nobody

unread,
Nov 14, 2009, 10:55:05 PM11/14/09
to
"Larry Serflaten" <serf...@usinternet.com> wrote in message
news:ONAm0UaZ...@TK2MSFTNGP06.phx.gbl...

I see 9:10 too. I think Google shows ET, but I am not sure. If you look at
that thread, when I said "off topic" you will see the time of that post at
6:03 PM, followed by you at 5:05 PM, which doesn't make sense unless it was
6:05 instead of 5:05.


Larry Serflaten

unread,
Nov 14, 2009, 10:49:57 PM11/14/09
to

"Nobody" <nob...@nobody.com> wrote

> > Do you still think its off?
>
> I see 9:10 too. I think Google shows ET, but I am not sure. If you look at
> that thread, when I said "off topic" you will see the time of that post at
> 6:03 PM, followed by you at 5:05 PM, which doesn't make sense unless it was
> 6:05 instead of 5:05.

What if you're an hour late? The message I am replying to says it was
posted at 10:55, yet its only 10:49 here....

I'm using OE connected to news.microsoft.com....

Oh well!
LFS


Larry Serflaten

unread,
Nov 15, 2009, 12:53:13 AM11/15/09
to

"Nobody" <nob...@nobody.com> wrote

> Seen at 22:10 hours ET, but shows 21:10 hours ET. Must be your newsserver.
> Your posts seems to go into time warp and appear in the past(they get
> inserted in the middle). I am using MS newsserver.

Thanks for noticing that. Apparently my clock was still on Daylight Saving Time.
It took me a while to notice it because that fact isn't listed on the TimeZone
tab of my system clock app. I had the box checked to automaticaly adjust for
daylight savings changes, but evidently it did not make the change this year.
Now that I recall, I had to manually set the clock to get back in sync with other
sources.

Had you not pointed it out, I certainly wouldn't have noticed.
Thanks!
LFS


Mike Williams

unread,
Nov 15, 2009, 5:31:26 AM11/15/09
to
"Larry Serflaten" <serf...@usinternet.com> wrote in message
news:eGiHu7XZ...@TK2MSFTNGP04.phx.gbl...

> I just tried using a large thumbnail image (3500, 3500 twips)
> and found the array method also ran out of memory.

As far as the limitation on the number of thumbnails you can store you'll
probably find a big improvement if you use DIBSections for the thumbnails,
which can be a bit smaller than an Autoredraw image and which are not so
fussy about the kind of memory they'll live in.

Regarding the speed issue, the loading from disk of the original is not the
biggest bottleneck. In fact you'll probably find that the code runs four or
five times faster when you run it on a folder full of equivalent .bmp
images, even though the amount of data being loaded from disk is in such a
case probably about ten times as much as it would be for jpgs. The majority
of time is actually taken up in decoding the jpg into a bitmap. This can be
improved by using the Intel jpg library, which can be up to four times
faster at decoding, depending on how you use it. Otherwise, you could grab
the "stored by the camera" thumbnails directly from the jpg file (unless the
jpg has since been modified and / or saved by an application which does not
preserve them). Check out:

http://www.vbaccelerator.com/home/VB/Code/Libraries/Shell_Projects/Thumbnail_Extraction/Thumbnail_Extractor_Code.asp

Mike

Mike Williams

unread,
Nov 15, 2009, 5:43:34 AM11/15/09
to
"Mike Williams" <Mi...@WhiskyAndCoke.com> wrote in message
news:Og1lI7d...@TK2MSFTNGP04.phx.gbl...


. . . Oops. The code at the link I posted extracts the Shell thumbnail, so
it will considerably speed up the process only where Shell thumbnails
actually exist (although I suspect that is the case on most systems). There
are other examples out there though that show how to extract the camera
thumnails from the jpg file (although I can't seem to put my hand on one at
the moment).

Mike

0 new messages