• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

Post reply

Other options

Shortcuts: ALT+S save/post or ALT+P preview

Topic summary

Posted by Galfar
 -  6 April 2010, 00:13:11
I would definitely use Asphyre if the target is Windows only. It has quite active forum and many examples (though many are for older versions). Latest edition can also directly use Imaging for loading images. 

Posted by dbots
 -  5 April 2010, 23:39:01
To display 32bit images in last version of unDelphiX, use :

form1.DXImageList1.Items.Find('image1dib').Draw(form1.DXDraw1.Surface, tmpx, 100, 0);

All work fine with that, except memory.

I tried to switch to Andorra 2D, since I read that it's not very difficult to transfer a project written for DelphiX to Andorra2D, but I found some unexplained parts there, asked the maintainer and got some answers but not all, so I started transferring my project, done almost half work and now I am stack.

With the code you sent, OK I can transform to DIB32 but the old DelphiX I use cannot handle alpha channels in DIB32. Only latest unDelphiX can, but this has the memory problems.
Also, the maintainer of unDelphiX has written a tool "PNG2DIB" that does exactly this. But as things are not, with that memory problem, I see no usage to do that.

I would like to have a quick solution for that problem I have now (displaying of DDS or PNG images) but of course if this is not possible I have to start using to other library.
But I would like the new library to :
- have very good support
- very good documentation and examples
- be able to do modern projects

Do you have any suggestions ?
Posted by Galfar
 -  5 April 2010, 22:38:31
In that last version of UnDelphiX which eats a lot of memory how do you display those 32bit images with alpha? You must use that TDXImageList or does it work with Surface.Draw as well?

With the code I sent you earlier you can convert any format with alpha channel (PNG, DDS, TGA, JNG, ...) to DIB32. Using TCanvas to draw anything is usually too slow for realtime usage.


I guess switching from DelphiX to another library is not an option for you, right?

Posted by dbots
 -  5 April 2010, 20:41:01
Quote from: Galfar on  5 April 2010, 19:37:58
Check out TDXImageList class mentioned in this forum thread http://delphigamedev.com/forums/viewtopic.php?f=2&t=1185.

I think you can't get any alpha blending simply by using Surface.Draw methods (http://www.gamedev.net/community/forums/topic.asp?topic_id=303701 - it would have to be hardware supported to work).


Thanks for replying. I have been using a previous version of DelphiX until now (before having the need to use images that contain alpha channels [dds/png]) and up to now everything was just fine.
I have also found this article you sent about TDXImagelist and tried that using the latest version of UnDelphiX, but that version has a very bad memory management. My project that with previous version used about 150 MB or RAM with everything loaded, compiled with new version and no other changes uses about 1,2 GB of RAM. Well, this is bad.
On the other hand, that latest UnDelphiX version displays 32bit bitmaps (with alpha channel) fine, but what can I do if memory management is so bad ?
I contact the maintainer of unDelphiX many times but had no reply about this so I returned back to previous version I used and try to find some other solutions to use together with that previous version of DelphiX.
BTW, that old version of DelphiX I use, supports hardware acceleration by using Do3D=TRUE and I use it like that - no problem with that.
What would you suggest ? (please note that if I could use PNG images that keep alpha channel, that also would be fine for me). As I wrote in the past, I used PNG images by adding PNGImage in the uses clause of my application, but the only way I could draw them so that they keep their alpha channel over DX surface, was by drawing on the canvas of the DXSurface (form1.dxdraw1.surface.canvas.draw) that needs a "form1.dxdraw1.surface.canvas.release" afterwards, not directly on the form1.dxdraw1.surface. So this (drawing on canvas) made things very slow on most systems.
Please send any suggestions.
Posted by Galfar
 -  5 April 2010, 19:37:58
Check out TDXImageList class mentioned in this forum thread http://delphigamedev.com/forums/viewtopic.php?f=2&t=1185.

I think you can't get any alpha blending simply by using Surface.Draw methods (http://www.gamedev.net/community/forums/topic.asp?topic_id=303701 - it would have to be hardware supported to work).
Posted by dbots
 -  4 April 2010, 20:43:30
Hi Galfar,

did you have any news please ?
(even on using PNG if DDS is a problem)

Thank you.
Posted by dbots
 -  3 April 2010, 17:45:57
Hi Galfar,
do you have any news about the problem with DDS ?
Please note that if it's possible to make it work even with PNG images for me it's fine, but keeping the alpha channel is the most important.
I tried and used pngimage in delphi but to make it work with DelphiX I have to use the dxdraw.surface.canvas.Draw and not the dxdraw.surface.Draw so this makes things much slower.
If you have any solution for PNG, please post.
Posted by dbots
 -  2 April 2010, 14:24:06
Hi, still no success. Currently with the code :


var
  Form1: TForm1;
  DIB : TDIB;
  img: TImageData;
  dxsurf : TDirectDrawSurface;

implementation

{$R *.dfm}

procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
begin
  form1.DXDraw1.Surface.Fill(clSilver);
  form1.DXDraw1.Surface.Draw(1,1,dxsurf);
  form1.DXDraw1.Flip;
end;

procedure TForm1.DXDraw1Initialize(Sender: TObject);
var linebytes,i : integer;
begin
  InitImage(img);
  LoadImageFromFile('mydds.dds', img);

  DIB := TDIB.Create;
  DIB.SetSize(img.Width, img.Height, 32);

  // make sure both are 32bit
  //DIB.BitCount := 32;

  ConvertImage(img, ifA8R8G8B8);

  // copy bits
  LineBytes := DIB.WidthBytes;
  for I := 0 to Img.Height - 1 do
    begin
    Move(PByteArray(Img.Bits)[I * LineBytes], DIB.Scanline[I]^, LineBytes);
    end;

  dxsurf := TDirectDrawSurface.Create(form1.DXDraw1.DDraw);
  dxsurf.LoadFromDIB(dib);

  form1.DXTimer1.Enabled := TRUE;
end;



I see the picture but with no alpha channel. It's like I have saved it as bitmap.

I used dib.savetofile to see if dib is OK but the problem starts from there. When I open this saved dib, it's like what I see - image is fine but with no alpha channel - like bitmap.

Note that DIB unit that I use is from unDelphiX - don't know if that makes any difference.
Posted by Galfar
 -  2 April 2010, 12:20:27
Looks like TDIB is bottom-top image, so try this instead of that single Move:


  LineBytes := DIB.WidthBytes;
  for I := 0 to Img.Height - 1 do
    Move(PByteArray(Img.Bits)[I * LineBytes], DIB.Scanline[I]^, LineBytes);
Posted by dbots
 -  2 April 2010, 09:10:04
Thank you for replying.

When I use

Move(img.Bits, DIB.PBits, img.Size);

I get error : Constant object cannot be passed as var paramater.
The syntax of Move (I use Delphi 7) is :
procedure  Move( const Source; var Dest; count : Integer );
Posted by Galfar
 -  2 April 2010, 03:55:19
This should convert TImageData to TDIB, test it please.

var
  DIB: TDIB;
  Img: TImageData;

... load DDS to Img ...

DIB := TDIB.Create;
DIB.SetSize(Img.Width, Img.Height);
// make sure both are 32bit
DIB.BitCount := 32;
ConvertImage(Img, ifA8R8G8B8);
// copy bits
Move(Img.Bits, DIB.PBits, Img.Size);

... now make surface out of DIB32 ...


How do you display the surface afterwards?


EDIT: There's some info about drawing images with alpha channel in DelphiX: http://delphigamedev.com/forums/viewtopic.php?f=2&t=1185

Posted by dbots
 -  2 April 2010, 00:20:26
Hi Galfar,

did you have any time to make that sample code ?

Thank you.
Posted by dbots
 - 31 March 2010, 22:21:28
Hi, just to inform, I tried :

  img := TImagingGraphic.Create;
  img.LoadFromFile('mydds.dds');
  dxsurf := TDirectDrawSurface.Create(form1.DXDraw1.DDraw);
  dxsurf.SetSize(img.Width, img.Height);
  dxsurf.Fill(0);
  dxsurf.LoadFromGraphic(img);

and I get the DDS image displayed but alpha channel is completely lost and I see some transparent parts on it- it's like having converted it to BMP and displaying a surface loaded from BMP.

If I add :

Move(img, dxsurf, SizeOf(img);

after

dxsurf.LoadFromGraphic(img);

then program hangs on that line with "Move".
Posted by dbots
 - 31 March 2010, 21:24:57
OK, I will wait for that, thank you.
Posted by Galfar
 - 31 March 2010, 21:13:47
TImagingGraphic loads all file types supported by Imaging, but saves only bitmaps. Saving is not needed though - try dxsurf.LoadFromGraphic(img)
Move(img, dxsurf, SizeOf(img);
and the other one is totally wrong, you can't use it like this.
I'll post some code for you to try later today.
SMF spam blocked by CleanTalk