Im trying to get a logo area from bitmap image i want to get only the area of the logo but it dosent

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
The file logoArea is 512x512
Now all the int variables are the area of the ogi wich is on the right bottom corner.
newimage is the image where i want to put the logo inside so in the end when im loading newimage in paint ill see only the logo.
But i want that newimage will be in the size of the logo only.

I cant understand it i used GIMP to get the excat x,y and x1,y1 and the x,y is 414,422 or so and the x1,y1 is the most bottom corner wich is 512,512 thats what the mouse told me when i put it on the bottom right corner.
but if i put 512 in y and y1 im getting error on Color logo_color = logoArea.GetPixel(x, y); or the SetPixel say it cant be less then height or something.
its only working for me like it is now but now im getting a new 512x512 image wich is black on the right bottom corner i see the logo and also not all of the logo but i see him.
I dont want a new 512x512 image i want to have a new image with the size of the logo with the logo only inside. I dont understadn what am i doing worng here ?

public static Bitmap logoArea(Bitmap logoArea)<br/>
{<br/>
int image_logo_area_x = 414;<br/>
int image_logo_area_y = 422;<br/>
int image_logo_area_x1 = 60;<br/>
int image_logo_area_y1 = 60;<br/>
Bitmap newimage;<br/>
newimage = new Bitmap(image_logo_area_x+image_logo_area_x1, image_logo_area_y+image_logo_area_y1);<br/>
int x, y;
for (x = image_logo_area_x; x < image_logo_area_x + image_logo_area_x1; x++)<br/>
{<br/>
for (y = image_logo_area_y; y < image_logo_area_y + image_logo_area_y1; y++)<br/>
{<br/>
Color logo_color = logoArea.GetPixel(x, y);<br/>
newimage.SetPixel(x, y, logo_color);
}<br/>
}<br/>
newimage.Save(@"e:logoarea.bmp", System.Drawing.Imaging.ImageFormat.Bmp);<br/>
return newimage;<br/>
}



Thanks. <hr class="sig danieli

View the full article
 
Back
Top