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
 WIC + Alpha Channel Bug ?
 New Topic  Reply to Topic
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

wesleybobato

Brazil
367 Posts

Posted - Feb 11 2016 :  11:27:18  Show Profile  Reply
Hi Nigel.

I found a problem with ImageEn + WIC.

When I open a PNG image with WIC and Saved.
Failure of Transparency.

I used Google Picasa to Best Exemplify.

Remembering that the Saved properly, ImageEn Problem only occurs with
WIC.

Thank you very much for your attention

attach/wesleybobato/2016211112628_WIC.zip
160.09 KB

https://www.dropbox.com/s/5rxrdvirbxocwen/WIC.mp4?dl=0

xequte

39052 Posts

Posted - Feb 11 2016 :  19:07:03  Show Profile  Reply
Hi Wesley

I've emailed you in response to your email.

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

wesleybobato

Brazil
367 Posts

Posted - Feb 21 2016 :  16:17:53  Show Profile  Reply
Hi Nigel
After Many Days Test.
I found that ImageEn, does not work correctly with TImage.
When we use PNG.

I added a Project Example.

You Can Check Please
Thank you Nigel.

#Code Here
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
 //Load Picture...
 Image1.Picture.Assign( ImageEnView1.Bitmap );
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 //Assign From TImageEnView...
 ImageEnView1.IO.LoadFromFile( 'C:\Users\Wesley\Desktop\RotateAndCrop\002.png' );
end;





attach/wesleybobato/2016221161718_TImage.zip
2348.97 KB
Go to Top of Page

xequte

39052 Posts

Posted - Feb 21 2016 :  19:35:36  Show Profile  Reply
Hi Wesley

Do you mean the transparency is not transferred? This is because you are assigning to the TImage has a bitmap, which means that you would need to transfer it as 32bit and I am not sure that TImage even supports
transparency of 32bit TBitmaps. Also, ImageEn does not assign the alpha channel with 32bit TBitmap.


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

wesleybobato

Brazil
367 Posts

Posted - Feb 21 2016 :  19:46:08  Show Profile  Reply
Nigel.

My Example Image Works Perfectly
With a PNG file with PixelFormat 32bit

I believe that lack Some code in ImageEn to create a Compatibility
Correct with TImage.

Thanks Again.
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - Feb 21 2016 :  19:50:07  Show Profile  Reply
Nigel.

To answer your question.
the only problem is that ImageEn does not transfer Correctly
the Transparency.

but ImageEn manages to capture Properly the Transparency of a TImage With Transparency.

I tried everything for days but ImageEn, does not transfer the information Transparency Correctly.

Thank you for your wonderful Attention.
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - Feb 21 2016 :  20:12:04  Show Profile  Reply
Hi Nigel

I studied the method CopyToTBitmap
At No Time This Procedure Renders AlphaChannel.

That is why I Said that This Incomplete this method.
I think.

Thank you very much for your attention.
Go to Top of Page

xequte

39052 Posts

Posted - Feb 21 2016 :  20:55:52  Show Profile  Reply
Hi Wesley

No, it does not, and I've added that to the to-do list. But have you confirmed that TImage will even support the transparency of a 32bit TBitmap (not a PNG)?


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

wesleybobato

Brazil
367 Posts

Posted - Feb 21 2016 :  21:44:55  Show Profile  Reply
Hi Nigel

I created an example and it worked Correctly.
Worked with TImage 2.

procedure TForm1.Button1Click(Sender: TObject);
var
 bmp: TBitmap;
begin
 bmp := TBitmap.Create;
  try

   if Image1.Picture.Bitmap.PixelFormat = pf32bit then
    begin
     bmp.Assign( Image1.Picture.Graphic );

     case bmp.PixelFormat of
       pfDevice: ;
       pf1bit: ;
       pf4bit: ;
       pf8bit: ;
       pf15bit: ;
       pf16bit: ;
       pf24bit: ;

       pf32bit:
        begin
         Image2.Picture.Bitmap.Assign( bmp );
         Image2.Invalidate;
       end;

       pfCustom: ;
     end;

    end;

  finally
   bmp.Free;
  end;

end;

Thank you very much for your attention.
Go to Top of Page

xequte

39052 Posts

Posted - Feb 22 2016 :  03:05:08  Show Profile  Reply
Hi

Please post your source 32bit BMP file (not a PNG).

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

wesleybobato

Brazil
367 Posts

Posted - Feb 22 2016 :  07:06:19  Show Profile  Reply
Hi Nigel.

https://pngtobmp32.codeplex.com/



Thank you for your attention.

Best regards.

attach/wesleybobato/201622282521_Bmp32.zip
947.71 KB
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - Feb 22 2016 :  12:59:07  Show Profile  Reply


Go to Top of Page

xequte

39052 Posts

Posted - Feb 22 2016 :  16:42:53  Show Profile  Reply
Hi

I cannot get TImage to show the alpha channel of this BMP file.



procedure TForm1.Button1Click(Sender: TObject);
var
 bmp: TBitmap;
begin
  bmp := TBitmap.Create;
  try
    bmp.LoadFromFile( 'd:\201622282427_Bmp32.bmp' );
    if bmp.PixelFormat <> pf32bit then
      ShowMessage( 'NOT 32BIT!' );
    Image2.Picture.Bitmap.Assign( bmp );
    Image2.Invalidate;
  finally
    bmp.Free;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Image2.Picture.LoadFromFile( 'd:\201622282427_Bmp32.bmp' );
  if Image2.Picture.Bitmap.PixelFormat <> pf32bit then
    ShowMessage( 'NOT 32BIT!' );
end;



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

wesleybobato

Brazil
367 Posts

Posted - Feb 22 2016 :  16:52:13  Show Profile  Reply
Hi Nigel

TImage Has a property equal to ImageEn.

Thank you for your attention.

Image1.Transparent := True;
ImageEnView1.EnabledAlphaChannel := True;
Go to Top of Page

xequte

39052 Posts

Posted - Feb 23 2016 :  12:52:17  Show Profile  Reply
I don't think TImage.Transparent and TImageEnView.EnabledAlphaChannel are equivalent. TImage.Transparent just makes the background transparent (defined as the color of the corner pixel). At least that is how it used to be.

I have confirmed that TImage will honor the alpha channel of a BMP if I call:

Image2.Picture.Bitmap.AlphaFormat := afDefined;

At any rate, ImageEn does not yet support the alpha channel of 32bit BMP files, but I have added it to the To-do list.

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

wesleybobato

Brazil
367 Posts

Posted - Feb 23 2016 :  13:58:33  Show Profile  Reply
Hi Nigel.

I did a test with your suggestion with TImage.

And Worked Normally.

Thank you for your attention.

Go to Top of Page

xequte

39052 Posts

Posted - Feb 28 2016 :  22:36:04  Show Profile  Reply
Some example code (requires ImageEn 6.2.3 or newer):

// Assign a 32bit Bitmap with alpha channel to an ImageEnView (keeping the alpha)
var
  bmp: TBitmap;
begin
  bmp := TBitmap.Create();
  bmp.LoadFromFile( 'Bmp32_with_Alpha.bmp' );
  ImageEnView1.IEBitmap.Assign( bmp );
  ImageEnView1.IEBitmap.SynchronizeRGBA( true );
  ImageEnView1.Update();
  bmp.Free();
end;

// Create a 32bit Bitmap with alpha channel
var
  bmp: TBitmap;
begin
  bmp := TBitmap.Create();
  ImageEnView1.IEBitmap.SynchronizeRGBA( false );
  ImageEnView1.IEBitmap.CopyToTBitmap( bmp );
  bmp.SaveToFile( 'test.bmp' );
  bmp.Free();
end;


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

wesleybobato

Brazil
367 Posts

Posted - Feb 29 2016 :  08:38:56  Show Profile  Reply
Hi Nigel.

Thank you very much for your attention.
I found the correct solution by reading the Manual.

Have a wonderful Day.

ImageEn, unit iexBitmaps

TIOParams.BMP_HandleTransparency

TIOParams.BMP_HandleTransparency




Declaration

property BMP_HandleTransparency: Boolean;



Description

BMP files can have up to 32 bits per pixel. This property controls how to interpret the extra byte in the 32 bit word.
When BMP_HandleTransparency is true the extra byte is interpreted as an alpha channel, otherwise it is just ignored.

So if BMP_HandleTransparency = True the image will be displayed in ImageEn with transparency. Whereas if BMP_HandleTransparency = False the transparent color will nto be used.



Example

// if BMP_HandleTransparency = true then display with transparency
ImageENVect1.IO.Params.BMP_HandleTransparency := chkBMPHandleTransparency.Checked;
ImageENVect1.IO.LoadFromFile( FilePath );
Go to Top of Page

xequte

39052 Posts

Posted - Feb 29 2016 :  16:41:32  Show Profile  Reply
Hi Wesley

I have improved the documentation to make these properties more obvious.

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

wesleybobato

Brazil
367 Posts

Posted - Feb 29 2016 :  17:53:46  Show Profile  Reply
Hi Nigel

Thank you for your attention.

Unfortunately with WIC does not work properly.
Because WIC does not respect the parameters of settings. IO

Can you check please?

Thank you very much.

ImageEnView1.IO.Params.BMP_HandleTransparency := True;
ImageEnView1.IEBitmap.WicRead( 'Bmp32_with_Alpha.bmp' , 0, ImageEnView1.IO.Params );
ImageEnView1.Update;
Go to Top of Page

xequte

39052 Posts

Posted - Mar 02 2016 :  16:33:35  Show Profile  Reply
Hi Wesley

WIC loading in ImageEn is not intended as a replacement for our internal Bitmap handling. Please do not use it if you require support for alpha, meta data, etc.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Reply to Topic
Jump To: