Click here to Skip to main content
15,908,111 members

Comments by merkousha (Top 2 by date)

merkousha 19-Sep-11 1:41am View    
Thank you SAKrykov ,

This Code is my solution ,
It's opened an ".emf" file and saved needed section of it in a new bitmap item .
And process bitmap to find goal pixel !
Read it , and give me an idea , how I can do this , without converting vector file to bitmap . (for reducing process time)
Or have you any other idea about reducing this process's time ?
I think that my Code explains clearly about my goals.



My new optimized code is :



<pre lang="c#"> int maxx,maxy,j,i=1;
j = 0;
for (i = 1; i <= 100; i++)
{
Metafile metafile1 = new Metafile(@"e:\pix\emf\sample - Copy (" + i.ToString() + ").emf");
Bitmap newBitmap = new Bitmap(metafile1.Width / 40, metafile1.Height / 20);
newBitmap.SetResolution(300.0F, 300.0F);
Graphics myGraphics = Graphics.FromImage(newBitmap);
myGraphics.FillRectangle(new SolidBrush(Color.White), new Rectangle(0, 0, metafile1.Width / 20, metafile1.Height / 20));
Rectangle rcSrc = new Rectangle(metafile1.Width / 2, 0, metafile1.Width , metafile1.Height / 2);
Rectangle rcDest = new Rectangle(0, 0, metafile1.Width / 20, metafile1.Height / 20);
myGraphics.DrawImage(metafile1, rcDest, rcSrc, GraphicsUnit.Pixel);
newBitmap.Save(@"e:\pix\bmp\sample - Copy (" + i.ToString() + ").bmp");
maxx = 0;
maxy = newBitmap.Height;

int i1,j1;
for (i1 = newBitmap.Width-1; i1 >= newBitmap.Width - 20; i1--)
for (j1 = 1; j1 <= 30; j1++) {
Color pixelColor = newBitmap.GetPixel(i1, j1);
if (pixelColor.Name != "ffffffff") {
if (i1 > maxx || i1>=maxx && j1 < maxy)
{
maxx = i1;
maxy = j1;
}
}
}

}
MessageBox.Show("Converting is finished !!!");

</pre>
merkousha 17-Sep-11 1:38am View    
dear SAKrykov ,
Thanks for your tracking .
I dont want to find any text .. I want to find the first black pixel in the right-top side of my vector (.emf) file .

how can I find the first black point in right-top side of my vector file . my .emf file is a black text in the White background .