Author |
Topic  |
wesleybobato
  
Brazil
367 Posts |
|
xequte
    
39052 Posts |
|
wesleybobato
  
Brazil
367 Posts |
Posted - Feb 21 2016 : 16:17:53
|
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 |
 |
|
xequte
    
39052 Posts |
Posted - Feb 21 2016 : 19:35:36
|
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
|
 |
|
wesleybobato
  
Brazil
367 Posts |
Posted - Feb 21 2016 : 19:46:08
|
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. |
 |
|
wesleybobato
  
Brazil
367 Posts |
Posted - Feb 21 2016 : 19:50:07
|
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. |
 |
|
wesleybobato
  
Brazil
367 Posts |
Posted - Feb 21 2016 : 20:12:04
|
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. |
 |
|
xequte
    
39052 Posts |
Posted - Feb 21 2016 : 20:55:52
|
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
|
 |
|
wesleybobato
  
Brazil
367 Posts |
Posted - Feb 21 2016 : 21:44:55
|
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. |
 |
|
xequte
    
39052 Posts |
|
wesleybobato
  
Brazil
367 Posts |
|
wesleybobato
  
Brazil
367 Posts |
Posted - Feb 22 2016 : 12:59:07
|
 |
 |
|
xequte
    
39052 Posts |
Posted - Feb 22 2016 : 16:42:53
|
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
|
 |
|
wesleybobato
  
Brazil
367 Posts |
Posted - Feb 22 2016 : 16:52:13
|
Hi Nigel
TImage Has a property equal to ImageEn.
Thank you for your attention.
Image1.Transparent := True; ImageEnView1.EnabledAlphaChannel := True; |
 |
|
xequte
    
39052 Posts |
Posted - Feb 23 2016 : 12:52:17
|
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
|
 |
|
wesleybobato
  
Brazil
367 Posts |
Posted - Feb 23 2016 : 13:58:33
|
Hi Nigel.
I did a test with your suggestion with TImage.
And Worked Normally.
Thank you for your attention.
 |
 |
|
xequte
    
39052 Posts |
Posted - Feb 28 2016 : 22:36:04
|
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
|
 |
|
wesleybobato
  
Brazil
367 Posts |
Posted - Feb 29 2016 : 08:38:56
|
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 ); |
 |
|
xequte
    
39052 Posts |
Posted - Feb 29 2016 : 16:41:32
|
Hi Wesley
I have improved the documentation to make these properties more obvious.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
 |
|
wesleybobato
  
Brazil
367 Posts |
Posted - Feb 29 2016 : 17:53:46
|
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; |
 |
|
xequte
    
39052 Posts |
Posted - Mar 02 2016 : 16:33:35
|
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
|
 |
|
Topic  |
|