> Read up on BitBlt and possibly StretchBlt, these calls will copy and in the
> later case also resize animagefrom one container to another, as long as
[quoted text clipped - 7 lines]
>
> - Show quoted text -
I'm running into some trouble getting BitBlt and StretchBlt to work
for me. I declare the function in my form like the following:
Private Declare Auto Function StretchBlt Lib "GDI32.DLL" _
(ByVal hdcDest As IntPtr, ByVal nXOriginDest As Integer, _
ByVal nYOriginDest As Integer, ByVal nWidthDest As Integer, _
ByVal nHeightDest As Integer, ByVal hdcSrc As IntPtr, _
ByVal nXOriginSrc As Integer, ByVal nYOriginSrc As Integer, _
ByVal nWidthSrc As Integer, ByVal nHeightSrc As Integer, _
ByVal dwRop As Int32) As Boolean
What I'm having trouble with is getting three images pasted into one
larger image. I have a function called drawDiagram() that creates my
graphs and returns them as a Graphics object. I make an initial call
to StretchBlt with my first graph. I think I then have to release the
HDC to my destination image. The result of this is that my
destination image is wiped clean. By the time I go to save my larger
destination image it is a plain white picture with no graphs located
on it. I'm also having trouble getting StretchBlt to save my graphs
in different XY coordinates on the destination graph. When I try to
StretchBlt just one graph in various places on the destination image
the graph always ends up at the top of the picture. Finally, I'm sure
I'm not disposing of all the objects that I should, I would appreciate
any help here as well. Here is my code:
ImageFile = New Bitmap(500, 660)
ImgFileGrphcs = Graphics.FromImage(ImageFile)
ImgFileGrphcs.FillRectangle(Brushes.White, 0, 0, ImageFile.Width,
ImageFile.Height)
If Color1.SelectedIndex = -1 Then
colorIndex = 0
Else
colorIndex = Color1.SelectedIndex
End If
SrcBitmap = drawDiagram(Cell1Image, Solution1.SelectedIndex - 1,
colorIndex)
Dim imghdc As IntPtr = ImgFileGrphcs.GetHdc
StretchBlt(imghdc, 0, 0, 500, 220, SrcBitmap.GetHdc, 0, 0, 500, 220,
SRCCOPY)
ImgFileGrphcs.ReleaseHdc(imghdc)
If Color3.SelectedIndex = -1 Then
colorIndex = 0
Else
colorIndex = Color3.SelectedIndex
End If
SrcBitmap.Dispose()
SrcBitmap = drawDiagram(Cell1Image, Solution3.SelectedIndex - 1,
colorIndex)
Dim imghdc2 As IntPtr = ImgFileGrphcs.GetHdc
StretchBlt(imghdc2, 0, 220, 500, 220, SrcBitmap.GetHdc, 0, 0, 500,
220, SRCCOPY)
ImgFileGrphcs.ReleaseHdc(imghdc2)
If Color5.SelectedIndex = -1 Then
colorIndex = 0
Else
colorIndex = Color5.SelectedIndex
End If
SrcBitmap.Dispose()
SrcBitmap = drawDiagram(Cell1Image, Solution5.SelectedIndex - 1,
colorIndex)
Dim imghdc3 As IntPtr = ImgFileGrphcs.GetHdc
StretchBlt(imghdc3, 0, 440, 500, 220, SrcBitmap.GetHdc, 0, 0, 500,
220, SRCCOPY)
ImgFileGrphcs.ReleaseHdc(imghdc3)
Brian
Thorsten Albers - 16 Nov 2007 23:40 GMT
toes <mcraven.2@wright.edu> schrieb im Beitrag
<01574b01-598e-43fc-9ba7-7ac2a1368a6f@s19g2000prg.googlegroups.com>...
> Private Declare Auto Function StretchBlt Lib "GDI32.DLL" _
> (ByVal hdcDest As IntPtr, ByVal nXOriginDest As Integer, _
[quoted text clipped - 6 lines]
> ImageFile = New Bitmap(500, 660)
> ImgFileGrphcs = Graphics.FromImage(ImageFile)
>> I forgot to mention that I want to be able to store the image as a
>> jpg, gif or bitmap.
You also forgot to mention that you are using VB.NET. This newsgroup is
dealing with VB <= 6.0 aka 'classic'. Although both are called 'VB' they
are not the same and have only few things in common. You should ask your
question in a (VB).NET newsgroup.

Signature
----------------------------------------------------------------------
THORSTEN ALBERS Universität Freiburg
albers@
uni-freiburg.de
----------------------------------------------------------------------