public Bitmap getEnergyImage() { double maxVal = 0; int w = energyImage.GetLength(0); int h = energyImage.GetLength(1); for (int i = 0; i < w; ++i) { for (int j = 0; j < h; ++j) { maxVal = Math.Max(maxVal, energyImage[i, j]); } } Bitmap energyResult = new Bitmap(w, h); LockBitmap lockEnergy = new LockBitmap(energyResult); lockEnergy.LockBits(); for (int i = 0; i < w; ++i) { for (int j = 0; j < h; ++j) { int map = (int)((energyImage[i, j] / maxVal) * 255.0); lockEnergy.SetPixel(i, j, Color.FromArgb(map, map, map)); } } lockEnergy.UnlockBits(); return(energyResult); }
private void fillColors() { imgColors = new Color[userImage.Width, userImage.Height]; LockBitmap lImg = new LockBitmap(userImage); lImg.LockBits(); for (int x = 0; x < userImage.Width; ++x) { for (int y = 0; y < userImage.Height; ++y) { imgColors[x, y] = lImg.GetPixel(x, y); } } lImg.UnlockBits(); }
private Bitmap createNewImage() { Bitmap resultImg = new Bitmap(newWidth, newHeight); LockBitmap lockRes = new LockBitmap(resultImg); lockRes.LockBits(); for (int x = 0; x < newWidth; ++x) { for (int y = 0; y < newHeight; ++y) { lockRes.SetPixel(x, y, imgColors[x, y]); } } lockRes.UnlockBits(); return(resultImg); }