Recent

Author Topic: PNG From Stream  (Read 3918 times)

lainz

  • Guest
PNG From Stream
« on: February 25, 2013, 07:13:45 pm »
Hi, please download and see the attached project.

I want to unzip to stream and create png image. I think that laz

This is for Custom Drawn Windows 7 Drawer, to zip all the png and the skin.ini file in a single zipped file.

I get 'This is not PNG-data' 'wrong image format'

Code: [Select]
  bmp.LoadFromStream(AStream, reader); 
What i'm doing wrong?

If is not possible I'll try with Lazarus Resources. But I've thinked on this because is more simple to update the skin files.

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: PNG From Stream
« Reply #1 on: February 25, 2013, 07:22:25 pm »
I  didn't check your example but I had similar problem when tried load exactly to specified graphic object. So I used TPicture which do some conversion between formats. Try with this:
Code: Pascal  [Select][+][-]
  1. var p: TPicture;
  2. begin
  3.   p := TPicture.Create;
  4.   try
  5.     p.LoadFromStream('<path>');
  6.     b := p.Bitmap;
  7.   finally
  8.     p.Free;
  9.   end;
  10. end;  
  11.  

lainz

  • Guest
Re: PNG From Stream
« Reply #2 on: February 25, 2013, 07:35:26 pm »
Mm doesn't works. The problem is that Zipper doesn't allow me use TStream and I've tryed TMemoryStream, maybe I'm using a wrong stream type.

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: PNG From Stream
« Reply #3 on: February 25, 2013, 07:39:19 pm »
Loading into memo changed strem position to the end. Change it again to 0:

  Memo1.Lines.LoadFromStream(Astream);
  AStream.Position := 0; 

Now there is no error but don't see any image

lainz

  • Guest
Re: PNG From Stream
« Reply #4 on: February 25, 2013, 07:48:29 pm »
Thankyou! It works =) Just resize the window.

Now I'll try to add to the drawer, and we will have a basic skin solution =)

Any suggestion for the file extension? I'll not use .zip, maybe .drawer?
« Last Edit: February 25, 2013, 10:06:35 pm by lainz »

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: PNG From Stream
« Reply #5 on: February 25, 2013, 10:58:18 pm »
Or some short "bdr" or something ;)

lainz

  • Guest
Re: PNG From Stream
« Reply #6 on: February 26, 2013, 12:43:22 am »
There is some limitation in any OS to length of extension?

I've searched "bdr" is from Microsoft  :o That's why I use long file extensions =)

Of course maybe some short extension like .skin is also used often and has 4 characters..

I think that I will keep zip, and in each application I use the zipped skins I will change the file extension. That's because if I want to do a file association it will cause problems (i.e user saying 'I can't install the skin').

Also if I put a general use file extension, i need to document that and i don't want to do it =)

If someone want to improve the format inside the zip (with other bitmap names, other format) skins will be not compatible ones with others.

lainz

  • Guest
Re: PNG From Stream
« Reply #7 on: February 26, 2013, 09:41:55 pm »
Well It's working, test the latest SVN of BGRAControls, now you can load 'skins' from zipped files, no more a folder with a lot of files  :D. It just has a heap on bitmap loading, maybe something easy to fix.

 

TinyPortal © 2005-2018