View+ Forum Index View+
Review http://mypsion.ru/viewplus.php
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   Join! (free) Join! (free)
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

View & Extract icons from AIF file

 
Post new topic   Reply to topic    View+ Forum Index -> ER5 OPL corner
View previous topic :: View next topic  
Author Message
Please Register and Login to this forum to stop seeing this advertsing.






Posted:     Post subject:

Back to top
Edo



Joined: 10 Aug 2005
Posts: 390


Location: Prismen - Vis

PostPosted: Sat Sep 24, 2005 1:53 pm    Post subject: View & Extract icons from AIF file Reply with quote

This code snippet enables you to view icons in AIF file and extract them to single MBM files.
It will always show all 4 icon sizes, as you see them in the system screen, using zoom function!
If some icon sizes are missing in AIF file, they will be extrapolated.
You can extract all icons at once or single icons (with or without masks).
Saved MBM files are named like File.mbm_icon16, File.mbm_icon24mask etc...

Edo



Code:

REM Code snippet - View and extract icons from AIF file
REM IconView ©Edo 23.09.05
REM Missing icons will be extrapolated If AIF doesn't contain all icon sizes!
REM Revo screen is too narrow for this snippet :(

CONST kTmpdir$ = "C:\System\Temp\"
CONST kLoading$ = "Loading icons..."
CONST kErrorMsg$ = "Problem reading AIF file - bad structure!!!"
CONST kAnyKey$ = "Any key to close"
CONST kNotAif$ = "Not an AIF file"
CONST kInit$ = "Initializing dialog..."
CONST kTitle$ = "IconView™"
CONST kUid1& = &10000037
CONST kUid2& = &1000006A

INCLUDE "AppInfo.oxh"
INCLUDE "Const.oph"

PROC Main:
   GLOBAL Win%
   LOCAL fileName$(255)

   TRAP MKDIR kTmpdir$
   gVISIBLE OFF
   gIPRINT kTitle$+" loaded"
dlg::
   BUSY kInit$
   IF LEN(fileName$)
   ELSE
      fileName$="C:\SYSTEM\APPS\"
   ENDIF

    dINIT kTitle$
   dTEXT "","Select AIF file to view & extract icons:"
   dFILE FileName$,"File,Folder,Disk",KDFileEditorQueryExisting% OR KDFileSelectorWithSystem% OR KDFileSelectorWithRom%, kUid1&, kUid2&, &0
   dBUTTONS "  Cancel  ", kkeyEsc%, "View", kkeyEnter%
   BUSY OFF
   IF 0 = DIALOG
      gIPRINT kTitle$+" unloaded"
      PAUSE -20
      RETURN
   ENDIF

   IF LOC(fileName$,".AIF")
      IF ShowIcons%:(fileName$)
         Loop:(fileName$)
      ELSE
         GOTO dlg::
      ENDIF
      TRAP DELETE kTmpdir$+"icon*"
      gCLOSE Win%
   ELSE
      gIPRINT kNotAif$
      GOTO dlg::
   ENDIF
ENDP

PROC ShowIcons%:(AifFile$)
   LOCAL icon$(255)

   BUSY kLoading$, 3
   gVISIBLE OFF
   icon$=kTmpdir$ + "icon"

   ONERR E
   AppExtractAifIcon:(AifFile$, 16, 0, icon$ + "16")
   AppExtractAifIcon:(AifFile$, 16, 1, icon$ + "16m")
   AppExtractAifIcon:(AifFile$, 24, 0, icon$ + "24")
   AppExtractAifIcon:(AifFile$, 24, 1, icon$ + "24m")
   AppExtractAifIcon:(AifFile$, 32, 0, icon$ + "32")
   AppExtractAifIcon:(AifFile$, 32, 1, icon$ + "32m")
   AppExtractAifIcon:(AifFile$, 48, 0, icon$ + "48")
   AppExtractAifIcon:(AifFile$, 48, 1, icon$ + "48m")

   Win% = gCREATE((gWIDTH-578)/2, (gHEIGHT-101)/2, 578, 101, 0, 1)
   gCOLORBACKGROUND $96, $96, $C8
   gAT 0, 0
   gFILL 578, 101, 1
   gXBORDER 2, $94

   Aifmbm:(icon$+"16", 5, 5, "")
   Aifmbm:(icon$+"16m", 76 ,5, " mask")
   Aifmbm:(icon$+"24",147, 5, "")
   Aifmbm:(icon$+"24m", 218, 5, " mask")
   Aifmbm:(icon$+"32", 289, 5, "")
   Aifmbm:(icon$+"32m", 360, 5, " mask")
   Aifmbm:(icon$+"48", 431, 5, "")
   Aifmbm:(icon$+"48m", 502, 5, " mask")
   gCOLOR $0, $0, $0
   gFONT KFontArialNormal11&
   gSTYLE 1
   gAT 35, 92
   gPRINT "What you see is what you get in the system screen (using zoom function)."
   gVISIBLE ON
   BUSY OFF
   RETURN KTrue%
E::
   ONERR OFF
   TRAP gCLOSE Win%
   TRAP DELETE kTmpdir$+"icon*"
   ErrorHandler:(kErrorMsg$,ERR)
ENDP

PROC Aifmbm:(name$, x%, y%, txt$)
   LOCAL iw%, w%, h%

   iw% = gLOADBIT(name$)
   w% = gWIDTH : h% = gHEIGHT
   gUSE Win%
   gCOLORBACKGROUND $FF, $FF, $FF
   gAT x%, y%
   gFILL 71, 71, 1
   gCOPY iw%,-2, -2, 71, 71, 0
   gBORDER 2, 71, 71
   gSTYLE 0 : gFONT 5
   gAT x% + 2,72
   gPRINT GEN$(w%,3) + "x" + GEN$(h%,3) + txt$
   gCLOSE iw%
ENDP

PROC AifExtract:(fileName$)
   LOCAL MBM$(255), icon$(7), save_all%, p%(6)

   BUSY "Wait..."
   MBM$=PARSE$(".", fileName$, p%()) + "mbm"
   dINIT "Extract icon and save as MBM file"
   dCHOICE choice%,"Icon","All icons,16x16,16x16mask,24x24,24x24mask,32x32,32x32mask,48x48,48x48mask"
   dFILE MBM$, "Name,Folder,Disk", KDFileEditBox% or KDFileEditorQueryExisting% or KDFileSelectorWithSystem%
   dBUTTONS "Cancel", kKEyEsc% OR $100, "Ok", kKeyEnter% OR $100
   BUSY OFF
   IF 0 = DIALOG
      RETURN
   ENDIF
   
   IF choice% = 1
      save_all% = KTrue%
   ELSE
      choice% = choice% - 1
   ENDIF

pick::
   VECTOR choice%
      icon16, icon16m, icon24, icon24m, icon32, icon32m, icon48, icon48m
   ENDV   
   icon16:: : icon$ = "icon16" : GOTO save::
   icon16m:: : icon$ = "icon16m" : GOTO save::
   icon24:: : icon$ = "icon24" : GOTO save::
   icon24m:: : icon$ = "icon24m" : GOTO save::
   icon32:: : icon$ = "icon32" : GOTO save::
   icon32m:: : icon$ = "icon32m" : GOTO save::
   icon48::   : icon$ = "icon48" : GOTO save::
   icon48m:: : icon$ = "icon48m"

save::
   TRAP COPY kTmpdir$ + icon$, MBM$ + "_"+icon$
   IF save_all%
      choice% = choice% + 1
      IF choice% < 9
         GOTO pick::
      ENDIF
      gIPRINT "MBM files saved"
   ELSE
      gIPRINT "MBM file saved"
   ENDIF
   PAUSE -20
ENDP

PROC Loop:(fileName$)
   GLOBAL choice%
   LOCAL Ev&(16)
   DO
      BUSY "Press “X” to extract icon, “Esc” to exit", 2
      GETEVENT32 Ev&()
      IF Ev&(kEvAType%) = ASC("x")
         AifExtract:(fileName$)
      ELSEIF Ev&(1) = kKeyEsc%
         BUSY OFF
         gIPRINT "Closing"+CHR$(133), 2
         PAUSE -20
         BREAK
      ENDIF
   UNTIL 0
ENDP

PROC ErrorHandler:(er$, err%)
   IF err% < 0
      BUSY OFF
      ALERT (er$, "", "", "")
   ENDIF
ENDP


Last edited by Edo on Sat Sep 24, 2005 9:56 pm; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail
Jonas



Joined: 10 Aug 2005
Posts: 74


Location: Stuttgart, Germany

PostPosted: Sat Sep 24, 2005 2:25 pm    Post subject: Reply with quote

Just a question:
Are we allowed to use your codes in our own program and to share this app, then? (Of course, I would say that it's from you, Edo Wink )

Greets, Jonas
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Edo



Joined: 10 Aug 2005
Posts: 390


Location: Prismen - Vis

PostPosted: Sat Sep 24, 2005 2:35 pm    Post subject: Reply with quote

Jonas wrote:
Just a question:
Are we allowed to use your codes in our own program and to share this app, then? (Of course, I would say that it's from you, Edo Wink )

Greets, Jonas


Of course you are allowed to use it, Jonas! That's why it's published here, to help you do something on your own
by following the example or just to change it in order to better suit your need.
Well, as usual, it's up to good manners to mention the source of the code you used Smile

Edo
Back to top
View user's profile Send private message Send e-mail
henk-jan



Joined: 16 Sep 2005
Posts: 10



PostPosted: Sun Sep 25, 2005 5:41 pm    Post subject: Reply with quote

Edo, you're great. So we can expect new programs en utilities written with you're help. It's good to realize epoc isn't dead. Unfortunately I can't program myself and don't have the time to learn it, so I'm depended on people like you (with thanks Laughing )
_________________
Henk-Jan Bezemer
Member of the Dutch Psiongroup
http://www.pdatotaal.info/portal.php?page=psion


Last edited by henk-jan on Mon Sep 26, 2005 1:53 pm; edited 1 time in total
Back to top
View user's profile Send private message
Edo



Joined: 10 Aug 2005
Posts: 390


Location: Prismen - Vis

PostPosted: Mon Sep 26, 2005 10:42 am    Post subject: Reply with quote

henk-jan wrote:
Edo, you're great. So we can expect new programs en utilities written we you're help. It's good to realize epoc isn't dead. Unfortunately I can't program myself and don't have the time to learn it, so I'm depended on people like you (with thanks Laughing )


Thanks Henk-Jan,

these code snippets are not just samples. If you paste them into OPL Editor
and translate, you actually get little utils which you can immediately use, without any intervention Laughing

Edo
Back to top
View user's profile Send private message Send e-mail
kees vd straten



Joined: 10 Aug 2005
Posts: 86


Location: The Netherlands

PostPosted: Tue Sep 27, 2005 10:27 am    Post subject: Reply with quote

henk-jan wrote:
Unfortunately I can't program myself, so I'm depended on people like you


Edo that's the same for me.



Edo wrote:
these code snippets are not just samples. If you paste them into OPL Editor
and translate, you actually get little utils which you can immediately use, without any intervention


Finding bug is easy for me, but programming.....

I did what you wrote, but after translation my nB says "Record too large"
What did I wrong?
_________________
Regards,

Kees.
Back to top
View user's profile Send private message Visit poster's website
Edo



Joined: 10 Aug 2005
Posts: 390


Location: Prismen - Vis

PostPosted: Tue Sep 27, 2005 12:00 pm    Post subject: Reply with quote

kees vd straten wrote:
henk-jan wrote:
Unfortunately I can't program myself, so I'm depended on people like you


Edo that's the same for me.


It's never late to start writing some code on your own. And, it's fun Wink

kees vd straten wrote:

Edo wrote:
these code snippets are not just samples. If you paste them into OPL Editor
and translate, you actually get little utils which you can immediately use, without any intervention


Finding bug is easy for me, but programming.....

I did what you wrote, but after translation my nB says "Record too large"
What did I wrong?


I don't know, since it goes OK for me!
Anyone else has problems translating/running this applet?

Edo
Back to top
View user's profile Send private message Send e-mail
kees vd straten



Joined: 10 Aug 2005
Posts: 86


Location: The Netherlands

PostPosted: Wed Sep 28, 2005 7:26 am    Post subject: Reply with quote

Edo wrote:

It's never late to start writing some code on your own. And, it's fun Wink



What I did was very very very simple, but it was fun!



_________________
Regards,

Kees.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    View+ Forum Index -> ER5 OPL corner All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Card File  Gallery  Forum Archive
Powered by phpBB © 2001, 2005 phpBB Group
Create your own free forum | Buy a domain to use with your forum
Free Web Counter