ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Convert Bitmap + transparent color to normal color
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

harry stahl

Germany
62 Posts

Posted - Jul 21 2016 :  16:09:17  Show Profile  Reply
Is there an integrated function in imageen that converts a bitmap that has an alphavalue to a colorvalue withouth Alpha?

So that the bitmap without alpha value shows the same color on screen like the bitmap with alphacolor value?

HS

w2m

USA
1990 Posts

Posted - Jul 21 2016 :  17:18:55  Show Profile  Reply
function DitherColor(AColor: TColor; AAlpha: Integer): TColor;
{ Dither a 32-bit color(with alpha value) to TColor.  This functions
  correctly for all colors except for clwhite. }
var
  iRGB: TRGB;
begin
  iRGB := TColor2TRGB(AColor);
  iRGB.r := Trunc(AAlpha / 255 * iRGB.r) + (255 - AAlpha);
  iRGB.g := Trunc(AAlpha / 255 * iRGB.g) + (255 - AAlpha);
  iRGB.b := Trunc(AAlpha / 255 * iRGB.b) + (255 - AAlpha);
  Result := TRGB2TColor(iRGB);
end;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

harry stahl

Germany
62 Posts

Posted - Jul 21 2016 :  17:44:00  Show Profile  Reply
Thank you very much Bill, for your answer. So I assume there is not a function for it in ImageEn?

Then this could be a version to handle white also:

function DitherColor(AColor: TColor; AAlpha: Integer): TColor;
{ Dither a 32-bit color(with alpha value) to TColor.}
var
  iRGB: TRGB;
begin
  iRGB := TColor2TRGB(AColor);

  if (iRGB.r = 255) and (iRGB.g = 255) and (iRGB.b = 255) then begin
    iRGB.r := AAlpha;
    iRGB.g := AAlpha;
    iRGB.b := AAlpha;
  end else begin
    iRGB.r := Trunc(AAlpha / 255 * iRGB.r) + (255 - AAlpha);
    iRGB.g := Trunc(AAlpha / 255 * iRGB.g) + (255 - AAlpha);
    iRGB.b := Trunc(AAlpha / 255 * iRGB.b) + (255 - AAlpha);
  end;

  Result := TRGB2TColor(iRGB);
end;



HS
Go to Top of Page

xequte

38611 Posts

Posted - Jul 26 2016 :  00:51:05  Show Profile  Reply
Hi

Added as IEApplyAlphaToColor() in v6.3.1.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

annieoroberts00

USA
5 Posts

Posted - Jul 29 2016 :  01:04:43  Show Profile  Reply
thanks for the info
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: