This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Drawing Images / Adding Borders as hard lines of pixels

I am trying to use the GDIGraphics object to combine two JPEG's into one image, and add a border around the images. I want the border to be a hard edge, where the pixel color of the border does not affect the images. Everytime i do this, however, the edges "blend" with the images and depending on the color of the border, it creates an ugly gray line.

Here's the code i'm trying to use:

   Dim canvas As New Aurigma.GraphicsMill.Drawing.GdiGraphics(bgBmp)

                canvas.DrawImage(profileImg, New PointF(picX, picY), Aurigma.GraphicsMill.Transforms.CombineMode.Copy, 1)
                canvas.DrawImage(pantsImg, New PointF(pantsX, pantsY), Aurigma.GraphicsMill.Transforms.CombineMode.Copy, 1)
                canvas.DrawString(imgStyle.TextValue, New Drawing.Font("Arial", 18, Drawing.FontStyle.Bold, GraphicsUnit.Pixel), _
                                New SolidBrush(Drawing.ColorTranslator.FromHtml(imgStyle.TextHex)), _
                                New Drawing.Point(DUBorderSize + 20, _
                                combHeight - DUBottomHeight - Math.Ceiling(Convert.ToDouble(DUBorderSize) / 2)))
                canvas.DrawRectangle(New Pen(Drawing.ColorTranslator.FromHtml(imgStyle.BorderColorHex), DUBorderSize), _
                                1, 1, DUWidth - DUBorderSize, profileImg.Height + (DUBorderSize))
                canvas.DrawRectangle(New Pen(Drawing.ColorTranslator.FromHtml(imgStyle.BorderColorHex), DUBorderSize), _
                                1, 1, DUWidth - DUBorderSize, profileImg.Height + (DUBorderSize))
 
                bgBmp.Save(sampleSavePath, New Aurigma.GraphicsMill.Codecs.JpegEncoderOptions(100, False))
                bgBmp.Dispose()


Any suggestions on accomplishing this task without losing the hard edges?

Thanks,
Brian
Hello Brian,

Could you try to save result image to TIFF without compression? Most likely this effect will disappear. Unfortunately it is limitation of JPEG format - this format is lossy, so when a JPEG image is decoded - some pixels can be blended.
Unfortunately I'm stuck with JPEG format. Any ideas on how I might at least cut back the amount of this? Would saving the image as TIFF and then saving as JPEG make any difference?

Thanks,
Brian
Hello Brian,

Could you submit case with your source JPEG images?