Extract From Bitmap Band/Strip

A

Analizer1

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);

}
 
P

Peter Duniho

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
 
A

Analizer1

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
 
P

Peter Duniho

[...]
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
 
A

Analizer1

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


Peter Duniho said:
[...]
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
 
P

Peter Duniho

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
 
A

Analizer1

i'll figure it out somehow...

thanks anyway

Peter Duniho said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top