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
 Transparency and PNG
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

bmesser

United Kingdom
224 Posts

Posted - Nov 25 2013 :  10:37:56  Show Profile  Reply
Hi

For a number of days now (or is it weeks), I have been trying to stitch nine PNG images into a 3x3 grid. I have just about used every technique available to man and ImageEN, but have been thwarted at every turn!

The images are small 256x256 coastal outlines, and as far as I can see they have 1 colour (black) and an Alpha channel for transparency. In the latest method I have thought up, I add each image as a new layer that I position in an ImageEnView component, I then merge the layers and save the file as a PNG, the resultant 768x768 image has NO transparency even though the individual file s do.

I have a work round at the moment were I manually use Paint.NET to flood fill the white with transparency, but obviously I would like to do this all in code.

Any help would be very much appreciated.

Bruce.

PS One odd thing about the images are that although they all display fine in Paint & Paint.NET with their transparency intact, they oddly appear black when loaded in IrfanView. If you would like to look at a very simple project and the images you can find the zip file here on my website:

http://www.xmetman.co.uk/StitchGrid.zip


bmesser

United Kingdom
224 Posts

Posted - Nov 26 2013 :  06:30:23  Show Profile  Reply
Fabrizio

I have run one of the PNG images through PNGCheck (http://sourceforge.net/projects/png-mng/) and according to that it's a valid 8-bit non-interlaced image.

Bruce.

Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 26 2013 :  07:41:21  Show Profile  Reply
Email Nigel and Fabrizio a few of the images.

William Miller
Go to Top of Page

Ruekaka

Germany
25 Posts

Posted - Nov 26 2013 :  08:28:08  Show Profile  Reply
Just because I'm also following this thread: The images are in the attached zip file.

With kind regards,
Ruediger Kabbasch
Go to Top of Page

xequte

38616 Posts

Posted - Nov 27 2013 :  15:50:36  Show Profile  Reply
Hi

You should find it easier to start with a transparent background and merge your images with that:

procedure TfmMain.CreateTiledImage;
const
  ncols = 3;
  nrows = 3;
var
  col    : integer;
  row    : integer;
  xpos   : integer;
  ypos   : integer;
  path   : string;
  url    : string;
  ABitmap: TIEBitmap;
begin
  Screen.Cursor := crHourGlass; 
  ABitmap := TIEBitmap.create;
  try
    ImageEnView1.LegacyBitmap := False;
    ImageEnView1.IEBitmap.Width  := 3*256;
    ImageEnView1.IEBitmap.Height := 3*256;
    ImageEnView1.EnableAlphaChannel := True;
    ImageEnView1.AlphaChannel.Fill(0);

    ypos := 0;
    for row := 0 to 2 do
    begin
      xpos := 0;

      for col := 0 to 2 do
      begin
        path := Format('Image%d%d.png',[col,row]);
        ABitmap.Read(path);
        ImageEnView1.IEBitmap.MergeWithAlpha(ABitmap, xpos, ypos);

        inc(xpos, 256);
      end;

      inc(ypos,256);
    end;     

    ImageEnView1.Update;

    if ImageEnView1.HasAlphaChannel = False then
      raise Exception.create('No Alpha channel!');

    ImageEnView1.IO.SaveToFilePNG('Image.png');
  finally
    Screen.Cursor := crDefault;
    ABitmap.free;
  end;
end;


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

bmesser

United Kingdom
224 Posts

Posted - Nov 29 2013 :  01:52:07  Show Profile  Reply
Hi Nigel

That works great!

Creating a transparent background did make the difference.

I was beginning to think it wasn't possible to do - so thank you very much for being so helpful.

Bruce.

PS Text book formatting by the way!
Go to Top of Page

xequte

38616 Posts

Posted - Nov 29 2013 :  12:49:58  Show Profile  Reply
quote:
PS Text book formatting by the way!

Everyone swears by CodeComplete, but the book that most made me change my craft was "The Pragmatic Programmer":

http://www.amazon.com/Pragmatic-Programmer-Journeyman-Master-ebook/dp/B000SEGEKI/

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