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
 OpenGL
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Tim Frost

United Kingdom
6 Posts

Posted - Jul 10 2013 :  07:16:43  Show Profile  Reply
Hi I am using ImageEn to load texture files for OpenGL. I have been using TImageEnIO with a TIEBitmap. However I want to be able to load and render in 64 bit RGBA (or BGRA). I have tried setting NativePixelFormat to true, but this does not seem to alter the format.

What is the best way to achieve this?

Thanks

Tim

fab

1310 Posts

Posted - Jul 15 2013 :  03:39:24  Show Profile  Reply
ImageEn doesn't support 64 bit RGBA, but only 32 bit RGBA. You can set 32 bit RGBA with:

ImageEnView.LegacyBitmap := false;
ImageEnView.IEBitmap.PixelFormat := ie32RGB;

There are limitation using ie32RGB (ie some image processing functions or resampling filters do not work...).
Go to Top of Page

Tim Frost

United Kingdom
6 Posts

Posted - Aug 08 2013 :  08:09:00  Show Profile  Reply
I am now back on this task.

I need to open a file and have the pixels in native format. I don't need a TImageEnView component as OpenGL will handle the dislay part.

I have tried this (with and TImageEnView component):
IEView->LegacyBitmap = false;
IEView->IO->NativePixelFormat = true;
IEView->IO->LoadFromFile(sFilename);

But whatever I do the format is alway 24bit RGB.

Could you give an example of how to open files in native format and how to extract the format from the IO->Params.

Thanks.
Go to Top of Page

Tim Frost

United Kingdom
6 Posts

Posted - Aug 08 2013 :  08:13:23  Show Profile  Reply
And...

I am using IEView->IO->IEBitmap->Memory to access the pixels, as I need a pointer to all of them to pass to OpenGL.
Go to Top of Page

fab

1310 Posts

Posted - Aug 15 2013 :  03:03:15  Show Profile  Reply
Native pixel format is not possible with ie32RGB format. You should convert to RGBA using the suggested code.
Go to Top of Page

Tim Frost

United Kingdom
6 Posts

Posted - Aug 15 2013 :  04:24:30  Show Profile  Reply
I have now more or less managed to open a file with an alpha channel. However I'd want to get the pixels in real RGBA or BGRA format, rather than haveing a separate bitmap for it. I have tried using:

if (IEView->IEBitmap->HasAlphaChannel)
{
IEView->IEBitmap->PixelFormat = ie32RGB;
IEView->IEBitmap->SynchronizeRGBA(true);
}

The pixel format is reset to ie24RGB when the file loads and it seemed that SynchronizeRGBA should put the alpha channel back in the right place. (using false makes no difference.)

What am I doing wrong?
Go to Top of Page

fab

1310 Posts

Posted - Aug 16 2013 :  03:46:39  Show Profile  Reply
You should call SynchronizeRGBA(false) to copy from alpha plane to the A channel of the RGBA pixel.
Executing following code:

  ImageEnView1->LegacyBitmap = false;
  ImageEnView1->IO->LoadFromFile("test.png");
  ImageEnView1->IEBitmap->PixelFormat = ie32RGB;
  ImageEnView1->IEBitmap->SynchronizeRGBA(false);
  ShowMessage(IntToStr(ImageEnView1->IEBitmap->Pixels_ie32RGB[0, 0].A));


"test.png" has the top-left pixel fully transparent (0), so this code shows correctly "0". Removing SynchronizeRGBA, shows "255" (not synched).
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: