P
Peter Oliphant
I want to create a new Bitmap which is a portion of an existing Bitmap. For
example, if I have a Bitmap that is 100x100 in size I might want to create a
new Bitmap that is equivalent to the one located at (x,y)=(10,20)
(upper-left hand corner) and is 50x50 in size of the source Bitmap. A
sub-Bitmap if you will, sort of the equivalent to sub-strings for a source
string.
I don't think this works, but something like:
Bitmap^ src_bm = gcnew Bitmap( "bm100x100.bmp" ) ;
Bitmap^ sub_bm = gcnew Bitmap( src_bm(Rectangle(10,20,50,50)) ) ;
Now I can do this via SLOW code ala creating the sub-bitmap of the proper
size and then copying pixels one-by-one from the source bitmap via GetPixel
and SetPixel. But I'm hoping that the construct for a sub-bitmap exists, as
it is quite natural. I can easily DRAW a sub-bitmap with the Graphics class,
but I want to create it as a new Bitmap.
Should I use the pixel-by-pixel method, or is there a faster and/or easier
way?
Thanx in advance for response!
[==Peter==]
PS - I'm developing in MS VC++ 2005 Express ala /cli (managed) code. This is
the Bitmap class I'm speaking of (since there may be more than one with the
same name but different namespaces):
ms-help://MS.VSExpressCC.v80/MS.NETFramework.v20.en/cpref8/html/T_System_Drawing_Image_Members.htm
example, if I have a Bitmap that is 100x100 in size I might want to create a
new Bitmap that is equivalent to the one located at (x,y)=(10,20)
(upper-left hand corner) and is 50x50 in size of the source Bitmap. A
sub-Bitmap if you will, sort of the equivalent to sub-strings for a source
string.
I don't think this works, but something like:
Bitmap^ src_bm = gcnew Bitmap( "bm100x100.bmp" ) ;
Bitmap^ sub_bm = gcnew Bitmap( src_bm(Rectangle(10,20,50,50)) ) ;
Now I can do this via SLOW code ala creating the sub-bitmap of the proper
size and then copying pixels one-by-one from the source bitmap via GetPixel
and SetPixel. But I'm hoping that the construct for a sub-bitmap exists, as
it is quite natural. I can easily DRAW a sub-bitmap with the Graphics class,
but I want to create it as a new Bitmap.
Should I use the pixel-by-pixel method, or is there a faster and/or easier
way?
Thanx in advance for response!
[==Peter==]
PS - I'm developing in MS VC++ 2005 Express ala /cli (managed) code. This is
the Bitmap class I'm speaking of (since there may be more than one with the
same name but different namespaces):
ms-help://MS.VSExpressCC.v80/MS.NETFramework.v20.en/cpref8/html/T_System_Drawing_Image_Members.htm