回复 1楼leadcom的帖子
LeadTools 获取特定坐标点可以使用 GetPixelColor 方法,请参考帮助文档:
https://www.leadtools.com/help/l ... ~getpixelcolor.html
关键代码:
- [TestMethod]
- public void GetPixelColorExample()
- {
- RasterCodecs codecs = new RasterCodecs();
- // Load the image
- RasterImage image = codecs.Load(Path.Combine(ImagesPath.Path, "IMAGE1.CMP"));
- // Specify a line of pixels.
- LeadPoint offset = new LeadPoint(image.Width / 8, image.Height / 8);
- int XSize = image.Width / 3;
- // Invert the colors of pixels in the line.
- for(int i = 0; i < XSize; i++)
- {
- LeadPoint oldOffset = new LeadPoint(offset.X, offset.Y);
- // Adjust the XOffset and YOffset in case the view perspective is not TopLeft.
- offset = image.PointToImage(Leadtools.RasterViewPerspective.TopLeft, offset);
- RasterColor pixelColor = image.GetPixelColor(offset.Y, offset.X);
- pixelColor.R = (byte)(255 - pixelColor.R);
- pixelColor.G = (byte)(255 - pixelColor.G);
- pixelColor.B = (byte)(255 - pixelColor.B);
- image.SetPixelColor(offset.Y, offset.X, pixelColor);
- offset = oldOffset; // Restore Offset
- offset.X = offset.X + 1;
- }
- codecs.Save(image, Path.Combine(ImagesPath.Path, "IMAGE1_GetPixelColor.BMP"), RasterImageFormat.Bmp, 0);
- image.Dispose();
- codecs.Dispose();
- }
复制代码 |