Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: FMX - Get number of bits per pixel


This question is not answered. Helpful answers available: 1. Correct answers available: 1.


Permlink Replies: 5 - Last Post: Jan 30, 2015 3:57 AM Last Post By: Tom Brunberg
André Diel

Posts: 27
Registered: 7/28/07
FMX - Get number of bits per pixel  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 29, 2015 5:48 AM
Hello,

In Delphi XE5 FMX,

How do I get the number of bits per pixel in the image?

I tried "Image1.Bitmap.BytesPerPixel" but it always returns me 4.

Thanks
Tom Brunberg

Posts: 329
Registered: 12/27/04
Re: FMX - Get number of bits per pixel
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 29, 2015 6:09 AM   in response to: André Diel in response to: André Diel
André Diel wrote:

Hello,

In Delphi XE5 FMX,

How do I get the number of bits per pixel in the image?

I tried "Image1.Bitmap.BytesPerPixel" but it always returns me 4.

Thanks

Look at PixelFormat property.
Descaription is here:
http://docwiki.embarcadero.com/Libraries/XE7/en/FMX.Types.TPixelFormat

Cheers

--
Tom Brunberg
firstname.lastname@welho.com
André Diel

Posts: 27
Registered: 7/28/07
Re: FMX - Get number of bits per pixel  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 29, 2015 8:17 AM   in response to: Tom Brunberg in response to: Tom Brunberg
Tom Brunberg wrote:

Look at PixelFormat property.
Descaription is here:
http://docwiki.embarcadero.com/Libraries/XE7/en/FMX.Types.TPixelFormat

Cheers

Ok,
But it seems that in XE5 it creates all bitmaps with type 'pfA8R8G8B8'.
Right?

I have 3 images with different bit depths (24, 8 and 4) and in all return is 4.

Thanks.
Tom Brunberg

Posts: 329
Registered: 12/27/04
Re: FMX - Get number of bits per pixel  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 29, 2015 11:46 AM   in response to: André Diel in response to: André Diel
André Diel wrote:

Tom Brunberg wrote:

Look at PixelFormat property.
Descaription is here:
http://docwiki.embarcadero.com/Libraries/XE7/en/FMX.Types.TPixelFormat

Cheers

Ok,
But it seems that in XE5 it creates all bitmaps with type 'pfA8R8G8B8'.
Right?

I have 3 images with different bit depths (24, 8 and 4) and in all return is 4.

Thanks.

I assume you mean Ord(PixelFormat) is 4 for all images after loading into TImage?
How do you load the files?
What type of files are they, .bmp, .jpg, .png ...?
I haven't investigated, but it could well be that they are autoconverted to 32 bit.

--
Tom Brunberg
firstname.lastname@welho.com
André Diel

Posts: 27
Registered: 7/28/07
Re: FMX - Get number of bits per pixel  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 30, 2015 2:32 AM   in response to: Tom Brunberg in response to: Tom Brunberg
Tom Brunberg wrote:
I assume you mean Ord(PixelFormat) is 4 for all images after loading into TImage?
How do you load the files?
What type of files are they, .bmp, .jpg, .png ...?
I haven't investigated, but it could well be that they are autoconverted to 32 bit.
Thanks for answering ...

Yes, that's it.

I create images like this:
"image.Bitmap: = TBitmap.CreateFromFile (files [i]);"
Where "var files: TStrings"
But I also tested it in design mode by MultiResBitmap property.

The types of images are .bmp and .jpg

Thanks

Tom Brunberg

Posts: 329
Registered: 12/27/04
Re: FMX - Get number of bits per pixel  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 30, 2015 3:57 AM   in response to: André Diel in response to: André Diel
André Diel wrote:

Tom Brunberg wrote:
I assume you mean Ord(PixelFormat) is 4 for all images after loading into TImage?
How do you load the files?
What type of files are they, .bmp, .jpg, .png ...?
I haven't investigated, but it could well be that they are autoconverted to 32 bit.
Thanks for answering ...

Yes, that's it.

I create images like this:
"image.Bitmap: = TBitmap.CreateFromFile (files [i]);"
Where "var files: TStrings"
But I also tested it in design mode by MultiResBitmap property.

The types of images are .bmp and .jpg

André,
After my post yesterday, I also made some tests (with .png and .bmp files). With the .png files,
which are 32 bit by nature, the result was of course the same pixel format. The same was also true
for 16-color, 4 bit .bmp files. IOW same result as you see.
The same was true also for a TBitmap created just in memory (no TImage or other controls involved).
I then did some googling and found some discussions suggesting that FMX always uses internally the
same os the underlying OS (all my tests on Windows), thus converting lower bit depth images.

Based on previous I am pretty sure, autoconversion takes place and it can't be prevented.

--
Tom Brunberg
firstname.lastname@welho.com

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02