ARTICLE AD BOX
Thanks to @d4zed and @JonasH, I have a coloured image appearin!
The answer was twofold. In the code I posted, the "rgbx" needed to be replaced with "bgrx", and the PixelFormat needed to be extracted from the bitmap itself. This gives:
private HImage ToHImage(Bitmap bitmap) { HImage ret = new(); var bInfo = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, bitmap.PixelFormat); ret.GenImageInterleaved(bInfo.Scan0, "bgrx", bitmap.Width, bitmap.Height, 0, "byte", 0, 0, 0, 0, -1, 0); bitmap.UnlockBits(bInfo); return ret; }However, the second problem was that I was using:
halconWindow.DispImage(hImage)
to display the image. This displays a greyscale image (yes, the documentation says this. I just didn't read it very well. My bad (and dumb name for a method)).
The correct method is:
halconWindow.DispColor(hImage)
The various HalconWIndow functions are here:
