1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| unsafe private void bInverser_Click(object sender, EventArgs e)
{
if (inpBox == true) //Si il y a une image dans la boîte à image
{
tsProgressBar.Visible = true; //Affiche la barre de progression
Bitmap bmp = new Bitmap((Bitmap)img[i]);
PixelFormat pf = bmp.PixelFormat;
Rectangle rc = new Rectangle(0, 0, bmp.Width, bmp.Height);
BitmapData bmpData = bmp.LockBits(rc, ImageLockMode.ReadWrite, pf);
Pixel32Data* pdeb, pfin, tmp, pDébut = (Pixel32Data*)bmpData.Scan0;
tmp = pdeb = pDébut;
pfin = pDébut + (bmp.Width * bmp.Height);
for (int li = 0; li < bmp.Height/2; li++)
{
for (int col = 0; col < bmp.Width; col++)
{
*tmp = *pfin;
*pfin = *pdeb;
*pdeb = *tmp;
pdeb++;
pfin--;
}
tsProgressBar.PerformStep(); //Incrémente la barre de progression "tsProgressBar"
}
bmp.UnlockBits(bmpData);
img[i] = bmp; //Place la nouvelle image dans la liste
pBox.Image = bmp; //Place la nouvelle image inversée dans la boîte à image
tsProgressBar.Value = 0; //Remet la barre de progression à 0
tsProgressBar.Visible = false; //Affiche la barre de progression
tsEtatImage.Text = (etatimg[i] = "Inversée").ToString(); //Nouvelle information sur l'état de l'image
}
} |
Partager