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 

MBMView code snippet/applet

 
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: Wed Sep 28, 2005 5:08 pm    Post subject: MBMView code snippet/applet Reply with quote

MBMView enables you to view (scroll) bitmaps in (multi)MBM files and to save them.
You can extract bitmaps from ROM-drive too, Jonas Wink
It's the simplest viewer and at the same time enough powerful Cool
It's only 1KB big and consists of only 2 procedures Rolling Eyes

Edo



Code:

REM MBMView code snippet ©Edo   28.09.05.
REM View MBM files (Scroll & Save bitmaps)

INCLUDE "Const.oph"
INCLUDE "System.oxh"

PROC Main:
   GLOBAL MBM$(255)
   LOCAL i%, Ev&(16), p%(6)
 
start::
   AT 2, 1 : PRINT "MBM view - code applet ©Edo 2005" + REPT$(" ", 27)
   AT 2, 2 : PRINT "Select MBM file" + REPT$(" ", 50)

   dINIT "MBM view", KDlgButRight%
   dFILE MBM$, "MBM file:", KDFileSelectorWithSystem% OR KDFileSelectorWithRom%
   dBUTTONS "Cancel",KDButtonEsc%, "Ok",KDButtonEnter%
   BUSY OFF
   IF 0 = DIALOG
      RETURN
   ENDIF

   AT 2, 1 : PRINT "--> RIGHT arrow  <-- LEFT arrow  /  SAVE - “S” / ESC - Exit"
   AT 2, 2 : PRINT "File:", MBM$
   AT 2, 3 : PRINT "Bitmap "
   
   ONERR End::
   Draw:(0, 0)
   WHILE KTrue%
      DO
         GETEVENT32 Ev&()
         IF Ev&(KEvAType%) = kKeyRightArrow32%
            i% = i% + 1
            ONERR Lastbitmap
            Draw:(i%, 0)
            CONTINUE
Lastbitmap::
            ONERR OFF
            gIPRINT "Last bitmap", 2
            i% = i% - 1
            CONTINUE
         ELSEIF Ev&(KEvAType%) = kKeyLeftArrow32%
            i% = i% - 1
            IF i% < 0
               i%=0
               gIPRINT "First bitmap", 2
               CONTINUE
            ENDIF
            Draw:(i%, 0)
         ELSEIF Ev&(KEvAType%) = ASC("s")
            Draw:(i%, 1)
         ELSEIF Ev&(KEvAType%) = kKeyEsc%
            gIPRINT "Closing"+CHR$(133),2
            PAUSE -20
            STOP
         ENDIF
      UNTIL 0
   ENDWH
End::
   ONERR OFF
   IF i%
   ELSE
      AT 2, 3 : PRINT "Error viewing file!"
      BUSY "Getting dialog"+CHR$(133)
      GOTO start::
   ENDIF
ENDP

PROC Draw:(bit%, save%)
   LOCAL ypos%, xpos%, width%, height%, bitmap%, p%(6), name$(255)

   ypos%=45 : xpos%=10
   bitmap% = gLOADBIT(MBM$, KgLoadBitReadOnly%, bit%)
   width% = gWIDTH : height% = gHEIGHT
   AT 9, 3 : PRINT RIGHT$("000"+GEN$(bit%,3),3), "("+NUM$(width%, 4)+"x"+NUM$(height%, 4)+" pixels)"+REPT$(" ",10)
   gUSE 1
   gAT xpos% - 1, ypos% - 1
   gFILL gWIDTH, gHEIGHT, KGModeClear%
   gGREY 1
   gBOX width% + 2, height% + 2
   gAT xpos%, ypos%
   gCOPY bitmap%, 0, 0, width%, height%, 3

   IF save%
      name$ = PARSE$(".", MBM$, p%()) + RIGHT$("000"+GEN$(bit%,3),3) + ".mbm"
save::
      name$ = SaveAsFileDialog$:(name$,#(0))
      IF LEN(name$)
         IF LEFT$(name$, 1) = "Z"
            gIPRINT "Cannot save to ROM-drive", 2
            GOTO save::
         ENDIF
         gUSE bitmap%
         gSAVEBIT name$
         gIPRINT name$+" saved", 2
      ENDIF
   ENDIF
   gCLOSE bitmap%
ENDP



Back to top
View user's profile Send private message Send e-mail
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