INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Usefull Functions & Procedures

Extract the icons stored into an "ico" file by vgulielmus
Posted: 3 Jan 15

An "ico" file usually contains more than a single icon (icons with different resolution / number of colors)
The following function extract the icons stored from a "ico" file into separate files (each icon into its own file), and can be used for "cur" files as well

CODE --> Foxpro

LOCAL lcFName,lcFContent,lnIcoNo,lni,lcExtrIco,lnBytes,lnOffset

lcFName = GETFILE("ICO;CUR")
IF EMPTY(m.lcFName)
	RETURN "No file"
ENDIF
lcFContent = FILETOSTR(m.lcFName)
IF LEFT(m.lcFContent,2) <> CHR(0) + CHR(0)
	RETURN "No valid Ico file"
ENDIF

IF !INLIST(SUBSTR(m.lcFContent,3,2) , CHR(1) + CHR(0) , CHR(2) + CHR(0))
	RETURN "No valid Ico file"
ENDIF

lnIcoNo = CTOBIN(SUBSTR(m.lcFContent,5,2),'RS')
FOR lni = 1 TO m.lnIcoNo
	lcExtrIco = LEFT(m.lcFContent,4) + CHR(1) + CHR(0)
	lnBytes = CTOBIN(SUBSTR(m.lcFContent,7 + 8 + 16 * (m.lni-1),4),'RS')
	lnOffset = CTOBIN(SUBSTR(m.lcFContent,7 + 12 + 16 * (m.lni-1),4),'RS')
	lcExtrIco = m.lcExtrIco + SUBSTR(m.lcFContent,7 + 16 * (m.lni-1),12) + CHR(0x16) + CHR(0) + CHR(0) + CHR(0)
	lcExtrIco = m.lcExtrIco + SUBSTR(m.lcFContent,1 + m.lnOffset, m.lnBytes)
	STRTOFILE(m.lcExtrIco,FORCEEXT('ico'+TRANSFORM(m.lni)+SYS(2015),JUSTEXT(m.lcFName)))
NEXT
RETURN TRANSFORM(m.lnIcoNo) + " files generated" 

http://en.wikipedia.org/wiki/ICO_%28file_format%29

Vilhelm-Ion Praisach

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close