On 08/05/2013 15:17, DaveO wrote:
>>> Dim VPic As PictureBox
>>> Set VPic.Picture = picTest.Picture
>
> **********************************
> Ooops, that line should have read:
> Set VPic = picTest
> **********************************
That explains it then, you're not copying any picture, you're just using
two different names to talk to the same PictureBox control.
> All I want is to be able to use a virtual PictureBox in the same way as a
> real one but without the overhead of actually showing anything.
Then use a hidden PictureBox.
Note that some graphics operations (to a screen DC) are clipped to the
visible area.
If the control is hidden, they may not work.
> So I want to take a copy of what is displayed, fart about with the
> copy but not affect the original in any way, and then save the
> resultant picture to a file.
Use a proper DIBSection and it will be completely off screen, but you
need to switch to using GDI or wrapper methods.
> Using a variable as a PictureBox seemed ideal but I cannot get it to work.
> I suppose I could work with a StdPicture but I'd still need to copy the
> content to a PictureBox or similar because the StdPicture does not expose
> any hDC and I really need a hDC for my write Jpeg routine (An entirely self
> contained module based on a class by John Korejwa).
No, the StdPicture is a bitmap handle and block of memory, you can
change the underlying memory, but not using nice drawing methods.
>> You may want to investigate the VB6 DIBSection implementations
>> that are floating around the internet.
>
> Already use some of that sauce in the Jpeg stuff however it does seem a bit
> of a sledgehammer when I only want to crack a small nut.
Not really, that's exactly what a DIBSection and DC is, a bitmap and a
drawing surface. Using a full visible PictureBox is the sledgehammer as
it has other stuff and limitations thrown in.
It also makes it fully device independent so it can work on low colour
depth machines (if such a beast exists any more)