On Jun 23, 2:40 am, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
> > I'm writing a simple screen capture program that is using the Bitmap
> > class to save the capture. I would like to do multiple captures and
[quoted text clipped - 15 lines]
>
> Pete
I see your point. I would like to not have to save it at all. There
is a possibility that there will be multiple bitmaps captured one
after another. I guess I just don't know how to save all of the
references to them and be able to access them later by some sort of
index. My function is:
' Grab the selected piece of the image.
Dim rect As New Rectangle( _
Min(m_X1, m_X2), Min(m_Y1, m_Y2), _
Abs(m_X1 - m_X2), Abs(m_Y1 - m_Y2))
Dim bm As Bitmap = DirectCast( _
m_bmDesktop.Clone(rect, m_bmDesktop.PixelFormat), Bitmap)
' Save the image into the file.
bm.Save(file_name, ImageFormat.Jpeg)
So, instead of bm.save, I would like to create some sort of collection
that I can reference later. Can someone give me a pointer on how to
do that?
Thanks, Chris
Peter Duniho - 28 Jun 2007 03:53 GMT
> [...]
> So, instead of bm.save, I would like to create some sort of collection
> that I can reference later. Can someone give me a pointer on how to
> do that?
How about an array? There are a number of potential solutions that are
either arrays or are array-like, all very basic data structures that
should be known to anyone attempting to write any useful program. Or put
another way, if you want to write useful programs, it sounds as though you
may want to educate yourself a little more on basic data structures common
to all programming environments.
As far as your specific question goes, some examples of data structures
that would be useful to you:
Dim arrayOfBitmaps As List(Of Bitmap)
Dim arrayOfBitmaps As ArrayList
Dim arrayOfBitmaps() As Bitmap
Any of those variable declarations will result in a variable named
"arrayOfBitmaps" in which you can store an arbitrary number of Bitmap
instances. With the first two, you can add new elements using an Add()
method each of the classes has. I believe with the third, you would need
to use ReDim() to resize the array as new items are added, if you did not
intially create an array large enough for all of your items.
Hope that helps.
Pete
Stupid48 - 28 Jun 2007 15:37 GMT
On Jun 27, 7:53 pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
> > [...]
> > So, instead of bm.save, I would like to create some sort of collection
[quoted text clipped - 25 lines]
>
> Pete
Thanks for the info. I didn't know that one could put these datatypes
in an array. I guess being a novice, I have a lot to learn but I
guess we all have to start somewhere....
Peter Duniho - 28 Jun 2007 17:36 GMT
> Thanks for the info. I didn't know that one could put these datatypes
> in an array. I guess being a novice, I have a lot to learn but I
> guess we all have to start somewhere....
Yup, that's true. We did all start somewhere, and we did all have a
moment when we had to learn what you can put into an array. This just
happened to be yours. :)