Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Extract From Bitmap Band/Strip

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Analizer1 - 15 Mar 2008 18:12 GMT
Below I can Draw a portion of a Bitmap to a control

what i would like to do is Save the Portion of a Bitmap
strip to a new bitmap 32x32
Can anybody help with this
Thanks

private void pictureBox2_Paint(object sender, PaintEventArgs e)

{

Console.WriteLine(this.pictureBox1.Image.Height);

Bitmap sourceImage = (Bitmap)this.pictureBox1.Image; //.Image;

// Define The Part of Original bit map ive show to the form in a Picturebox

//256 below points to the 7th picture in the source bitmap

Rectangle sourceRectangle = new Rectangle(256,0,32,32);

//define the rectangle where to draw on the control  this picture box

Rectangle destinationRectangle = new Rectangle(0, 0, 32, 32);

// And this procedure draws it for us. Easy. OR IS IT?

e.Graphics.DrawImage(sourceImage, destinationRectangle, sourceRectangle,
GraphicsUnit.Pixel);

//DrawFromStripBitmap(sourceImage, pictureBox3,3);

}
Peter Duniho - 15 Mar 2008 19:17 GMT
> Below I can Draw a portion of a Bitmap to a control
>
> what i would like to do is Save the Portion of a Bitmap
> strip to a new bitmap 32x32
> Can anybody help with this

I was helping with this, in a different thread that you'd started  
earlier.  Why are you creating a new thread for the same question?

As far as the code you posted goes, I don't understand why your source  
image is in a PictureBox in the first place, but assuming it is, then it's  
not appropriate to handle that PictureBox's Paint event for the purpose of  
copying a portion of one bitmap to another, nor is it appropriate to use  
the Graphics instance passed for the Paint event to do the copying.

If you want to copy part of one bitmap into another, you need to use the  
Graphics.FromImage() method to get a Graphics instance that can be used to  
draw into the destination bitmap, and then call DrawImage() on that  
Graphics instance, passing the source bitmap to that method.

It's highly unlikely that you would call that code in the context of  
handling a Paint event (though it's not at all uncommon that you might  
copy a portion of the source bitmap directly to the  
PaintEventArgs.Graphics instance in a Paint event...it just depends on how  
you're using the bitmap strip).

Pete
Analizer1 - 15 Mar 2008 20:04 GMT
The Code I just posted
was Test Code , just trying to get a portion of a bitmap on the screeen, ie
trying to learn all the graphic stuff in net

What i want to do is extract part of the original bitmap strip into a new
bitmap....

i do appriciate your  help
thanks

>> Below I can Draw a portion of a Bitmap to a control
>>
[quoted text clipped - 23 lines]
>
> Pete
Peter Duniho - 15 Mar 2008 20:12 GMT
> [...]
> What i want to do is extract part of the original bitmap strip into a new
> bitmap....

My previous post includes an explanation as to how you might do that.  If  
you have a specific question about that explanation, I'm happy to try to  
elaborate.  But you'll have to ask that specific question.

Pete
Analizer1 - 15 Mar 2008 20:32 GMT
I give up....
I just said , what i wanted to do...and i do not know how
so therefore , there is no question, because i dont know what to ask

>> [...]
>> What i want to do is extract part of the original bitmap strip into a new
[quoted text clipped - 5 lines]
>
> Pete
Peter Duniho - 15 Mar 2008 21:03 GMT
> I give up....
> I just said , what i wanted to do...and i do not know how
> so therefore , there is no question, because i dont know what to ask

I know you said what you want to do.  I already explained, in my previous  
post, how to do what you want to do.

So, your original question has already been answered.

Now, if you have a problem understanding that answer or otherwise being  
able to use it, that's fine.  But you need to clearly state what problem  
it is you have.  Otherwise, all that anyone can do is restate what I've  
already written.  Obviously there's no point in doing that.

Pete
Analizer1 - 15 Mar 2008 22:01 GMT
i'll figure it out somehow...

thanks anyway

>> I give up....
>> I just said , what i wanted to do...and i do not know how
[quoted text clipped - 11 lines]
>
> Pete

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.