Author Topic: Black background when rotate an image  (Read 1484 times)

Offline dec

  • Imaging User
  • *
  • Posts: 3
    • View Profile
Black background when rotate an image
« on: 19 January 2013, 18:13:49 »
Hello,

First of all, thank you very much for your work at Vampyre Imaging Library, in my opinion one of the best tools to work with images from Delphi. I have a question that cannot solved by myself. When rotate an image (supose a Bitmap) using "Imaging.RotateImage()", we have some option in order to set the background color instead get the "default" black background?

Thank you very much in advance.

Offline dec

  • Imaging User
  • *
  • Posts: 3
    • View Profile
Re: Black background when rotate an image
« Reply #1 on: 29 January 2013, 16:31:00 »
Hello there,

I continue needed some help with the above question. Can somebody help me? Thanks!

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 354
    • View Profile
    • Galfar's Homepage
Re: Black background when rotate an image
« Reply #2 on: 15 February 2013, 01:52:48 »
Hello,
unfortunately it's not possible to set the background color with currently implemented rotation method.
One option is to blend the rotated image to another image filled with desired background color.
Image to be rotated must be converted to some format with alpha channel - background after rotation will
be not only black but also transparent.

Check out Deskew for code to merge image with background:
https://bitbucket.org/galfar/app-deskew/src/d9ee5df8742884404bf8df06ed7e0b2aab88ee8f/ImageUtils.pas?at=default#cl-149

Offline dec

  • Imaging User
  • *
  • Posts: 3
    • View Profile
Re: Black background when rotate an image
« Reply #3 on: 15 February 2013, 17:46:35 »
Hello,

Thank you for your answer Galfar. I'll take a look at your refered code. Thank you again.