Post Reply 
Program "Magnifying Glass" to use everywhere
09-30-2015, 08:09 PM (This post was last modified: 09-30-2015 09:19 PM by xset.)
Post: #1
Program "Magnifying Glass" to use everywhere
Hey,

I just implemented my dream. Funny concept but quite useful in some cases.
This program allow you to call magnifying glass everywhere on calculator, it also can be called by opening its application. Look MGlassDemo.png in attached archive.

[Image: cd5ef55b7523.png]

You press Shift-USER M (+/- key on keyboard) and glass appeared, you can drag and view anything better. Exit with On button (i promise graceful exit by ESC in next version).

Application's "MagnyGlass" program (don't forget to add images MGlass.png and MskGlass.png from archive to Files section of application):
Code:

EXPORT MagnyGlass()
BEGIN
  LOCAL DX:=28; // center of glass offset X
  LOCAL DY:=29; // offset Y
  LOCAL X:=50; // Current center of glass position X
  LOCAL Y:=50; // Y
  LOCAL GW:=120; // Width of glass image
  LOCAL GH:=76;   // Height
  LOCAL SW:=GROBW_P(G0); // Width of screen
  LOCAL SH:=GROBH_P(G0); // Height of screen
  DIMGROB_P(G1,SW,SH); // FOR SCREEN COPY
  BLIT_P(G1,G0);             // Save copy of screen
  G2:=MagnyGlass.AFiles("MGlass.png"); // Load image of glass
  G3:=MagnyGlass.AFiles("MskGlass.png"); // Load mask of glass
  DIMGROB_P(G4,GW,GH); // prepare G4 GROB w size equal to glass image
  DIMGROB_P(G5,GW,GH); // prepare G5 GROB w size equal to glass image
WHILE 1 DO // Never make such inf loops :-)
  BLIT_P(G0,G1); // Restore image
  BLIT_P(G4,G1,X-DX,Y-DY,X-DX+GW,Y-DY+GH); // Save normal (non-stretched) version under image
  BLIT_P(G5,0,0,GW,GH,G1,X-15,Y-15,X+20,Y+15); // Save magnified version
  BLIT_P(G5,G3,#0000FF); // Put red mask of glass on magnified version
  BLIT_P(G0,X-DX,Y-DY,G5,#FF0000); // Put magnified version without (area inside glass)
  BLIT_P(G0,X-DX,Y-DY,G2,#FF0000); // Put glass without red (draw glass over normal image and magnified part)
  LOCAL msg:=WAIT(-1);
   IF TYPE(msg)=6 THEN
       IF msg(1)=0 OR msg(1)=1 THEN
            X:=msg(2)-86+28; // shift to handle 86 (need to drag glass by handle instead of center) and return to center 28
            Y:=msg(3)-56+29; // same for Y
       END;
   END;
END;
  BLIT_P(G0,G1); // Restore after inf loop (stupid idea).
END;

START()
BEGIN
   MagnyGlass();
END;

Key callback code in MagnyGlassKey.hpprg:
Code:

KEY K_Neg()
BEGIN
   MagnyGlass.MagnyGlass();  
END;


Attached File(s)
.zip  MagnyGlass.zip (Size: 40.04 KB / Downloads: 24)
Find all posts by this user
Quote this message in a reply
09-30-2015, 08:30 PM (This post was last modified: 09-30-2015 08:31 PM by primer.)
Post: #2
RE: Program "Magnifying Glass" to use everywhere
Brillant use of GROB functions ! (bliting, masking...)
that's very nice.
you gives ideas... Wink
thank you.

primer
Find all posts by this user
Quote this message in a reply
09-30-2015, 09:03 PM (This post was last modified: 09-30-2015 09:11 PM by xset.)
Post: #3
RE: Program "Magnifying Glass" to use everywhere
Oh, I am still learning basics. Someone even found alpha blending in RECT. Next dream is editor application with blackjack and...

I've improved a little comments in code.
Find all posts by this user
Quote this message in a reply
10-01-2015, 05:43 AM
Post: #4
RE: Program "Magnifying Glass" to use everywhere
Hello,

I LOVE it, it is a wonderful idea!

Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
10-01-2015, 08:12 PM
Post: #5
RE: Program "Magnifying Glass" to use everywhere
Yup... don't be surprised if something similar shows up in the future! :-D

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)