Important alert: (current site time 7/16/2013 2:40:26 AM EDT)
 

winzip icon

PNG Reader : Updated (by LaVolpe)

Email
Submitted on: 12/22/2005 4:13:48 AM
By: LaVolpe 
Level: Intermediate
User Rating: By 27 Users
Compatibility: VB 6.0
Views: 79287
author picture
(About the author)
 
     Work in progress & posted for your suggestions. This is a good PNG reader (includes progressive display/interlacing--rare indeed) & the writer is in progress & will be posted next month, hopefully. In order to use this, you'll need ZLIB.DLL and a link for a VB-friendly version of that free DLL is near the top of the main class. Currently not Win95/NT4 capable, but working on that too. Again, this is a work in progress. The PNG format contains many color-related "chunks" that I don't currently have the knowledge to implement. If you know how to handle any chunks that are unhandled in the project, please email me. In IDE, this thing crawls, but compiled it is up to 10x faster & can display full screen PNGs very quickly. Hoping to hear from you all. When the PNG Writer is ready, will repost with the changes--expected to be massive. Added step-by-step instructions at top of stdPNG class for using the zlib DLL. Tweaked to fix minor errors I mentioned in remarks below. Added a readme file, more properties/options (like global AlphaBlend), and more comments. I think the reader is now good to go pending any bug reports & my TODO list I added at top of the main class. The writer is next.

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 72 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

12/17/2005 5:36:08 AMenmity

please take a look at : http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=56537&lngWId=1
(If this comment was disrespectful, please report it.)

 
12/17/2005 6:06:05 AMRuturaj

It is really nice to see that somebody from VB World has taken PNG seriously. Please look for MNG as well. The structure of MNG is quite similar as GIF (I mean the way it packs image frames and stores frame-delay information in it).

There is a DLL called "FreeImage.dll" (developed in C). Few months ago a wrapper module for this DLL was available on TheVBZone.com website (now he has decided it to sell it for a few $$ !). This is really a nice DLL and I think its licensing issue is just like ZLib DLL. Not sure. Please checkout this FreeImage.dll; it really has some potential. By the way, really eager to see your PNG Maker. When it was required in one of my projcts, I used PajantImage Shareware OCX to create PNG/MNG images; just for your information.

Good start ... please continue ...

-- Ruturaj
(If this comment was disrespectful, please report it.)

 
12/17/2005 8:41:09 AMLaVolpe

Enmity; that post is what insprired this one. Ruturaj; I am familiar with FreeImage & wanted to try & do this w/o using that huge DLL. GDI+ can do PNGs also but has O/S rqmts & doesn't seem to handle all transparencies correctly--or I might just be using it wrong :) I'd imagine MNG would be very similar; want to finish understanding PNG first.
(If this comment was disrespectful, please report it.)

 
12/17/2005 9:02:22 AMLight Templer

Another step to the big project? ;-)
May ***** for! Regards - LiTe
(If this comment was disrespectful, please report it.)

 
12/17/2005 10:01:40 AMOricron

Now this is fantastic :) The speed, options etc. I love it...and can't wait to see it grow :)

I hope the save part will be as good as well...

Another thing would be nice (if it could be done): How about aplying an over all alpha (to blend the png with the background - with a specified alpha - and offcourse combined with the png's alpha)...

Also, how about some color settings? - the ability to apply a custom palette - like Winamp does with color schemes?

Othervise, it is fantastic....
(If this comment was disrespectful, please report it.)

 
12/17/2005 10:49:44 AMLaVolpe

LiTe-Thanx. Oricron; good ideas: 1) Overall alpha? Easy. 2) Palette swapping? For 256color & below only? If so, easy & will be available via a property that can be called during the ProgressiveDisplay event; just before PNG is converted to BMP. If for 24+bpp, then have no clue--suggestions? As for the Save part? That is going to be a 1st cut & others will have to provide feedback for optimizations. Filtering the PNG is what will be time consuming as their are 5 filter types. How to determine best/fastest method? PNG specs have hints, but not very informative. This will be trial & error I'm afraid.
(If this comment was disrespectful, please report it.)

 
12/17/2005 11:00:07 AMC. Kevin Provance

Why not just use gdiplus.dll and have the best of all worlds? gif, png, jpg, bmp, etc. I've been able to do more with it than with anything else. :)
(If this comment was disrespectful, please report it.)

 
12/17/2005 7:29:19 PMOption Explicit

Even unfinished, another phenomenal effort from you Keith. Maybe if I study hard I'll be able to understand some of it!
(If this comment was disrespectful, please report it.)

 
12/17/2005 11:06:28 PMHeriberto Mantilla Santamaria

doesn't work with my PNG images and missing zlibVB.dll.

Why?
(If this comment was disrespectful, please report it.)

 
12/17/2005 11:54:04 PMHerman

Just a piece of general feedback (1) This code has failed to open any of my PNG files (whereas the code posted by Alred Koppold has no such problem). (2) One does not need to use zLib to load PNG file - if use it in vb, have to use the earlier version. (3) "tRNS" is prohibited for color types 4 and 6, since a full alpha channel is already present in those cases. (4) Compared with MNG, animated GIF is like a kid. There is no comparison at all in terms of difficulties (e.g. all browsers can only handle a very limited no. of types of MNG, Paintshop Pro also). (5) Compareing to brossers, FreeImage.dll handles PNG differently (browsers invariably use white background) and FreeImage.dll cannot cope with many types of MNG).

(If this comment was disrespectful, please report it.)

 
12/18/2005 9:50:09 AMLaVolpe

For those of you that say it doesn't work or is missing the DLL, you didn't do as I asked and read the comments at the to of the class. It works on all PNGs I have tested: 100's. You didn't download the vb-friendly DLL from the site provided & didn't reanme it to zlibVB.dll and didn't place it in your systeem folder. Although Alfred's code can display PNGs w/o zlib, it cannot write PNGs.
(If this comment was disrespectful, please report it.)

 
12/18/2005 10:05:05 AMLaVolpe

ZLIB FYI: Why did I rename the dll to zlibVB.dll vs leaving it as zlib.dll? If you already had ZLIB on your system, I didn't want you overwriting it with the VB-friendly version unknowingly. Placing the extracted/renamed dll in you project folder will not work -- put it in the systtem folder. The version I gave links to in my project is the most current version of zlib as of 5 Dec 05.
(If this comment was disrespectful, please report it.)

 
12/18/2005 12:31:11 PMHeriberto Mantilla Santamaria

Hi LaVolpe.

I admire a lot their work and I aren't criticizing it, I clarify him that, I only want to inform you, so that you tell me that it can be happening and where I can discharge the zlibVB.dll.

Thanks for your help, I send you one of my PNG images.
(If this comment was disrespectful, please report it.)

 
12/19/2005 3:20:08 AMShkyrockett

Excelent! But if you realy want to make this dll free, check out Marco v/d Berg's Deflate64/Inflate64 classes at: http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=58473&lngWId=1 . You might want to do some testing, but in my experiance they work great with PNG compression.
(If this comment was disrespectful, please report it.)

 
12/19/2005 9:41:29 AMLaVolpe

Shkyrockett; will check that out. Thanx

(If this comment was disrespectful, please report it.)

 
12/19/2005 11:37:33 AMPhantom Man

Awesome piece of code Keith.

Gary
(If this comment was disrespectful, please report it.)

 
12/19/2005 1:07:08 PMLaVolpe

Note: 2 minor typos & can affect image:
1) InitializeMatrix: Replace only 256 with 256& << must be Long vs Integer. 2) ConvertPNGtoBMP. Find tColor = ((pIndex+2) & replace with tColor = (m_Palette(pIndex + 2).
(If this comment was disrespectful, please report it.)

 
12/19/2005 8:02:59 PMShkyrockett

After Looking through your code a little deaper; you might also want to check out Marco v/d Berg's other compression projects, especialy http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=53174&lngWId=1, which has a class to handle CRC32.
(If this comment was disrespectful, please report it.)

 
12/19/2005 8:54:39 PMLaVolpe

Note: Another oops. ExtractText routine. Not concatenating. Change sText=sKeyWord to sText=sText & sKeyWord in the chnk_zTXt section. Will probably post one more update here when I am satisfied with the options to remove/replace transparent bkg colors.
(If this comment was disrespectful, please report it.)

 
12/20/2005 10:07:39 AMLaVolpe

Shkyrockett, when I get the reader the way I want, I will do some speed comparisons with suggested links. If I find the VB-only code is significantly slower than using ZLib, I will keep ZLib & leave it to others to modify if desired. BTW, another coder mentioned that the CRC routine has a 64k limit before erroring out. Don't know for sure.
(If this comment was disrespectful, please report it.)

 
12/21/2005 4:27:01 PMRichard Mewett

Goldmine of information (as your submissions always are) on PNG processing and highly readable code. 5*
(If this comment was disrespectful, please report it.)

 
12/22/2005 8:51:23 AMLaVolpe

Last updated: 21 Dec late night.
(If this comment was disrespectful, please report it.)

 
1/13/2006 4:46:31 PMOption Explicit

NHGames, who are you to say something like that? Much less rate a one globe? You can't even code the simplest projects. Everyone search "NHGames" and see what garbage pops up... People like you are what make this site a joke.
(If this comment was disrespectful, please report it.)

 
1/13/2006 5:57:22 PMLaVolpe

Useless? Your vision appears to be short-sighted I would think. To each, their own opinions.
(If this comment was disrespectful, please report it.)

 
1/18/2006 9:19:21 AMFrancis Arnold G. Balatico

NHGames this ain't a useless project. Perhaps you just dont understand its concept, implementation, significance and overall code. LaVolpe's contributions have been the inspiration of a lot of programmers and commenting rudely is hardly acceptable for a person of his character.

BTW, nice work and please do continue, I've been learning a lot from you LaVolpe.
(If this comment was disrespectful, please report it.)

 
3/12/2006 2:28:35 AMRobert Rayment

Keith: Late comment - I found that to get the zlibvb.dll to be picked in the IDE when it is in the app folder only, just add App.Path (modified for backslash when in root) before "zlibvb.dll" in your ValidateDLLexists.
(If this comment was disrespectful, please report it.)

 
8/5/2006 2:32:00 PMPhoenixX_2

Amazing! Works very nicely!
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.