[RESOLVED] Combine Images
Yea i know already done a search :)
But this i guess is a little more complicated? I was wondering what would be the best way to load pictures into an array, then i need to store them side by side. I don't really want to use a picturebox but it seems that using .PaintPicture will be easiest so i am a little uncertain now as i wanted to try and keep away from pictureboxes :(
Re: [RESOLVED] Combine Images
Hi All,:)
Dear LaVolpe,:thumb::check:
Thanks a lot about the code below:)
1- I needed only to save the combined images in vertical way and not to show In The Form.
2- I need to be able to have unlimited Images Combined or (128000 pixels maximum). However, the combined image is limited to 16383 pixels wide, Whats a good practical way to be able to save 128000 pixels maximum?:)
Kind Regards,
Code:
' the picbox name: picCombined
Dim tmpPic As StdPicture
Dim picNr As Long
Dim sFileName As String
Dim maxCx As Long, maxCy As Long
Dim picWidth As Long, picHeight As Long
picCombined.ScaleMode = vbPixels
picCombined.AutoRedraw = True
picCombined.BorderStyle = 0&
' should add error checking in case VB can't load picture
' also, don't know if doing this for an entire folder, but error can occur
' if resources run too low
For picNr = 1 To 5
' add code needed to identify which file to upload
sFileName = ?????
Set tmpPic = LoadPicture(sFileName)
picWidth = ScaleX(tmpPic.Width, vbHimetric, vbPixels)
picHeight = ScaleY(tmpPic.Height, vbHimetric, vbPixels)
maxCx = maxCx + picWidth
If picHeight > maxCy Then maxCy = picHeight
picCombined.Move picCombined.Left, picCombined.Top, _
ScaleX(maxCx, vbPixels, Me.ScaleMode), _
ScaleY(maxCy, vbPixels, Me.ScaleMode)
picCombined.PaintPicture tmpPic, maxCx - picWidth, 0&, picWidth, picHeight
Next
SavePicture picCombined.Image, [FileName]
' good idea for releasing some resources to...
picCombined.AutoRedraw = False
picCombined.Cls
Re: [RESOLVED] Combine Images
xpertino, welcome to the forums
In the future, you should not start your own posting on someone else's posting. Rather, start your own post and you can reference another posting if you need to. If any moderators disagree with that statement, I'm sure they will let both of us know.
Your answers:
1. You will need to modify the code to shift stuff vertically vs horizontally. It is just that simple.
2. The sizes are limited. VB limits picturebox size and the size of the .Image and/or .Picture property can cause errors if it is too large and AutoRedraw is True, the error is generally something like "Can't create Active-X object". Even if one were to go with a complete API approach, the memory bitmap may be too large also. See post #6 above.
A possible solution may be to use more than one picturebox, where images 1-xx are in one box and images xx-last are in another box?
Re: [RESOLVED] Combine Images
Dear LaVolpe
Thanks Too Much For Your Support
Please, Can You Send An Example To Understanding How Combining Too Much Images The Combined Images Have Height More Or equal Than 128,000 Pixels.
And I Have Too Much Memory No Problem
Best Regards,