Re: PictureBox max width
- From: "Galen Somerville" <galen@xxxxxxxxxxxxxxxx>
- Date: Fri, 20 Jun 2008 07:30:57 -0700
"Mike Williams" <mikea@xxxxxxxxxxxxxxxxx> wrote in message
news:OnJFMcq0IHA.548@xxxxxxxxxxxxxxxxxxxxxxx
"Galen Somerville" <galen@xxxxxxxxxxxxxxxx> wrote in messageThanks for the code.
news:eyoni4k0IHA.4848@xxxxxxxxxxxxxxxxxxxxxxx
I actually made an app work up to 32,767 using two picture
boxes in tandem. Of course the Slider had to move both
boxes at the same time. Some of our files get up to 45,000+
bytes in length. I certainly don't want to use three boxes. My
Shadow control gets cumbersome even with two boxes.
Note exactly sure what you're doing there but do you really need such a
large image in memory? What is its exact purpose?
This has to do with Heart sounds and the ECG. Usually the height is only 100
to 150 pixels. The length depends on how many seconds of recording and the
rate (usually 2,500 Hz).
Usually we delete bytes at the start so the sound begins right after the ECG
pulse. However many times the sound towards the end is not good, probably
from stehoscope being moved, etc. So we need to remove bytes from the end of
the recording and that's the length of display problem.
Galen
Do you have an example of that API usage?
Yep. The maximum Width (or Height) of a memory bitmap (either a screen
compatible bitmap or a DIBSection) can be very much greater than the 16383
VB PictureBox limit. However, you still do need to remember that the
overall "total size" (the total pixel area) is still limited depending on
available memory (for screen compatible bitmaps) and on other restrictions
(for DIBSections) so if the Height of your desired bitmap is anywhere near
its required Width (you have mentioned possibly three times 32767) then
you are going to run into serious problems anyway. But if just one thing
(either the Height or the Width) is required to be very large with the
other dimension being fairly small or reasonable then you'll be okay.
Here's a quick example of the creation of a screen compatible memory
bitmap with a size of 95,000 pixels wide by 250 pixels high (an
approximate 95 MB bitmap on a 32 bit display). If your desired overall
size is very much larger than this amount, and especially if you are going
to run it on machines with limited memory, then you might instead wish to
use DIBSections (which are a bit smaller because a full colour 24 bit DIB
requires only three bytes per pixel) and which I believe can be paged to
disk, although you will still run into problems with DIBSections if you
ever get up to extremely large overall sizes.
Anyway, heres the example 95,000 x 250 pixel screen compatible memory
bitmap. The code first creates a DC and then creates a bitmap to go into
it and then draws a few white dots into the bitmap and then (just top
provde that they actually got drawn) it blits the very rightmost 200 pixel
band of the memory bitmap to the top left corner of your Form. Paste the
code into a VB Form containing one Command Button and run the code and
click the button.
Mike
Option Explicit
Private Declare Function CreateCompatibleDC Lib "gdi32" _
(ByVal hdc As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" _
(ByVal hdc As Long, _
ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function SelectObject Lib "gdi32" _
(ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" _
(ByVal hObject As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" _
(ByVal hdc As Long) As Long
Private Declare Function SetPixel Lib "gdi32" _
(ByVal hdc As Long, ByVal x As Long, ByVal y As Long, _
ByVal crColor As Long) As Long
Private Declare Function BitBlt Lib "gdi32" _
(ByVal hDestDC As Long, _
ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal hSrcDC As Long, _
ByVal xSrc As Long, ByVal ySrc As Long, _
ByVal dwRop As Long) As Long
Private Sub Command1_Click()
Dim x As Long, y As Long
x = 95000 ' 95,000 pixels wide
y = 250 ' 250 pixels high
Dim myDC As Long, mybmp As Long, oldbmp As Long
myDC = CreateCompatibleDC(Me.hdc)
mybmp = CreateCompatibleBitmap(Me.hdc, x, y)
If mybmp = 0 Then
MsgBox "Unable to create bitmap"
End If
oldbmp = SelectObject(myDC, mybmp)
' draw two white pixels near right side of very wide bitmap
SetPixel myDC, x - 100, 16, vbWhite
SetPixel myDC, x - 101, 16, vbWhite
' copy the "rightmost" 200 pixels of bitmap to Form
BitBlt Me.hdc, 0, 0, 200, y, myDC, x - 200, 0, vbSrcCopy
SelectObject myDC, oldbmp
DeleteObject mybmp
DeleteDC myDC
End Sub
Like you said, the Frames were
useless.
"Mike Williams" <mikea@xxxxxxxxxxxxxxxxx> wrote in message
news:O6hct9j0IHA.2064@xxxxxxxxxxxxxxxxxxxxxxx
"Galen Somerville" <galen@xxxxxxxxxxxxxxxx> wrote in messageDo you have an example of that API usage? Like you said, the Frames were
news:OocqXvY0IHA.2064@xxxxxxxxxxxxxxxxxxxxxxx
[1] Dim Temp as Long
Picture1.Width=30000
Temp = Picture1.Width
The result is, Temp = 30,000
But when I do this in a working app, well after Form
Load, Temp is always 16,383 for long width's
[2] Sheesh, I put the PictureBox in a Frame. Set the
frame width to Me.ScaleWidth and the picturebox
width to 45,000. Worked like a charm.
I'm afraid you're kidding yourself with the Frame Control, Galen. The
absolute maximum Width (or Height) of a VB6 PictureBox is 16383 pixels,
whether it is Autoredraw or not. That is why you were seeing a result of
1683 in your first test, because the Form's ScaleMode was probably set
to vbPixels.
It is also why it *appears* that you have managed to exceed that limit
when you dropped the PictureBox into a Frame. That is because a Frame
does not have a ScaleMode and so everything in a Frame is sized using
Twips as the scale units, regardless of the ScaleMode of the Frame's
container (normally the Form). So the 45,000 units you managed to
achieve on the PictureBox contained in a Frame Control was actually
45,000 twips, which on a standard 15 twips per pixel machine is just
3000 pixels.
I'm afraid 16383 pixels (or 245,745 twips on a standard 15 twips per
pixel machine) is the most you're going to get from a VB6 PictureBox.
You can of course create memory images very much larger than that, but
you need to use the API, not a VB6 PictureBox, to create your larger
sizes.
Mike
useless.
I actually made an app work up to 32,767 using two picture boxes in
tandem. Of course the Slider had to move both boxes at the same time.
Some of our files get up to 45,000+ bytes in length. I certainly don't
want to use three boxes. My Shadow control gets cumbersome even with two
boxes.
Galen
.
- Follow-Ups:
- Re: PictureBox max width
- From: Mike Williams
- Re: PictureBox max width
- References:
- PictureBox max width
- From: Galen Somerville
- Re: PictureBox max width
- From: Galen Somerville
- Re: PictureBox max width
- From: Mike Williams
- Re: PictureBox max width
- From: Galen Somerville
- Re: PictureBox max width
- From: Mike Williams
- PictureBox max width
- Prev by Date: Re: Icon loading problems in VB5
- Next by Date: Re: Icon loading problems in VB5
- Previous by thread: Re: PictureBox max width
- Next by thread: Re: PictureBox max width
- Index(es):