podkreśla mi unsafe, ktoś pomoże mi z tym??
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.IO;
namespace PrzetwarzanieObrazow
{
public partial class Korekcja : Form
{
PictureBox picture_1;
PictureBox picture_2;
public Korekcja(ref PictureBox pb1, ref PictureBox pb2)
{
InitializeComponent();
picture_1 = pb1;
picture_2 = pb2;
}
private void Przetwazaj()
{
Bitmap mapa_bitowa_we = (Bitmap)picture_1.Image;
Bitmap mapa_bitowa = (Bitmap)picture_2.Image;
BitmapData bmd_we = mapa_bitowa_we.LockBits(new Rectangle(0, 0,
mapa_bitowa.Width, mapa_bitowa_we.Height), ImageLockMode.ReadWrite,
mapa_bitowa_we.PixelFormat);
BitmapData bmd = mapa_bitowa.LockBits(new Rectangle(0, 0,
mapa_bitowa.Width, mapa_bitowa.Height), ImageLockMode.ReadWrite,
mapa_bitowa.PixelFormat);
unsafe
{
byte* wskWe = (byte*)bmd_we.Scan0;
byte* wskWy = (byte*)bmd.Scan0;
int nOffset = bmd.Stride - mapa_bitowa.Width * 3;
//********************************************
long wielko = ((IntPtr)((byte*)bmd.Scan0.ToInt64()
+ (long)mapa_bitowa.Width * (long)3 * ((long)mapa_bitowa.Height
+ (long)nOffset))).ToInt64();
int jas = trackBar1.Value;
int kon = trackBar2.Value;
float gam = (float)trackBar3.Value / 100;
//
byte[] LUT = new byte[256];
for (int i = 0; i < 255; i++)
{
LUT[i] = (byte)Math.Round((Math.Pow((float)i / 255, (float)1 / gam) * 255));
}
LUT[255] = 255;
int nowaWartosc = 0;
do
{
{
nowaWartosc = LUT[wskWe[0]];
nowaWartosc = (int)Math.Round(((nowaWartosc + kon)
- ((double)(nowaWartosc * kon) / 127) + jas));
if (nowaWartosc < 0) nowaWartosc = 0;
if (nowaWartosc > 255) nowaWartosc = 255;
wskWy[0] = (byte)nowaWartosc;
wskWy++; wskWe++;
}
wskWy += nOffset; wskWe += nOffset;
} while
((long)wskWy < wielko);
mapa_bitowa.UnlockBits(bmd);
mapa_bitowa_we.UnlockBits(bmd);
picture_2.Refresh();
}
}
private void trackBar1_Scroll(object sender, EventArgs e)
{
l_jasnosc.Text = trackBar1.Value.ToString();
}
private void trackBar2_Scroll(object sender, EventArgs e)
{
l_kontrast.Text = trackBar2.Value.ToString();
}
private void trackBar3_Scroll(object sender, EventArgs e)
{
l_gamma.Text = ((float)trackBar3.Value / 100).ToString();
}
private void trackBar_MouseUp(object sender, MouseEventArgs e)
{
Przetwazaj();
}
}
}