# Thread: How to copy RGB pixels from one to another bitmap?

1. ## How to copy RGB pixels from one to another bitmap?

I'll explain my scenario with pictures for better understanding.

1. What I want is the pixel width and height of the rgb pixels and create a new bitmap with those dimensions and copy RGB area pixels into it.

2. It would be even better if I can copy only the RGB area into a new bitmap without the transparent part (Is it possible?)

3. Else, Is there any other alternative?

2. ## Re: How to copy RGB pixels from one to another bitmap?

hi
Originally Posted by venu238
1. What I want is the pixel width and height of the rgb pixels and create a new bitmap with those dimensions and copy RGB area pixels into it.
=> reframing filter to selection your RGB rect
=> BitmapRenderer or WritealbeBitmapRenderer to copy the RGB area

2. It would be even better if I can copy only the RGB area into a new bitmap without the transparent part (Is it possible?)
what do you mean by "without the transparent part" ?

3. ## Re: How to copy RGB pixels from one to another bitmap?

1. How should I select a rectangle around the RGB?

2. Copying RGB pixels without alpha channel pixels into a new irregular shaped image

4. ## Re: How to copy RGB pixels from one to another bitmap?

Originally Posted by venu238
1. How should I select a rectangle around the RGB?
I do not know if there is some magical filter for that, but a simple pair of for loops can certainly get the rectangle
Code:
```int minx=Int.MaxValue,miny=Int.MaxValue,maxx=Int.MinValue,maxy=Int.MinValue;
for(int y=0;y<height;y++)
for(int x=0;x<width;x++)
if(getpixel(x,y)!=0)
{
if(minx>x)minx=x;
if(maxx<x)maxx=x;
if(miny>y)miny=y;
if(maxy<y)maxy=y;
}```
2. Copying RGB pixels without alpha channel pixels into a new irregular shaped image
Is there such thing as an "irregular shaped image"?

5. ## Re: How to copy RGB pixels from one to another bitmap?

1. Thanks for the reply, maybe GetPixel method is little time consuming..Is there any other alternative?

2.sorry language problem, I mean to say that copy RGB pixels to a path figure..

6. ## Re: How to copy RGB pixels from one to another bitmap?

Originally Posted by venu238
1. How should I select a rectangle around the RGB?
you want somethings automatic??

Originally Posted by venu238
2. Copying RGB pixels without alpha channel pixels into a new irregular shaped image
blend mode it's certainly the simplest. For the background, you could use a ColorImageSource

7. ## Re: How to copy RGB pixels from one to another bitmap?

Yeah I need something automatic..it will be user friendly.

I have got the rectangle dimensions with the help of "wizard_hu_".. what should I do next?
Use reframing filter?

8. ## Re: How to copy RGB pixels from one to another bitmap?

Reframing filter will do the stuff

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•