I have a HBITMAP which was created from using the CopyPicture method of Excel Interop. For some reason, this puts a grey border on the top and left hand edges of the image even though these are not part of the spreadsheet. Could someone tell me an easy way of removing these borders from the image. The way I thought of is getting the bits in a bytearray, removing the first row and column from this byte array and then converting the array back to a bitmap. Is there an easier or better way? Like just a simple trim function?
Share
If you know the dimensions of the border, you can crop the bitmap by creating a copy with
clonewith a new bounding box applied:This crops the
srcbitmap withrand places a copy intoresult.