Access and change rgb values of pixels

Access and change rgb values of pixels

Issue : Access and change rgb values of pixels.

Tips : To access and change rgb values of pixels there can be used LoadPixels method.

Example :

using Aspose.Imaging;
using Aspose.Imaging.FileFormats.Png;
using Aspose.Imaging.FileFormats.Tiff;
using Aspose.Imaging.FileFormats.Tiff.Enums;
using Aspose.Imaging.ImageOptions;
using System.Collections.Generic;
using System.IO;
using System.Linq;
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
string dataDir = templatesFolder;
using (TiffImage image = (TiffImage)Image.Load(dataDir + "template.tiff"))
{
Color[] colors = image.LoadPixels(image.Bounds);
int length = colors.Length;
for (int i = 0; i < length; i++)
{
if (i % 2 == 0)
{
colors[i] = Color.Red;
}
}
image.SavePixels(image.Bounds, colors);
image.Save(dataDir + "result.png", new PngOptions());
}
File.Delete(dataDir + "result.png");