Book & Viewer & Magnify

Share your advanced PureBasic knowledge/code with the community.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Comic Book / Magnifying Glass

Post by JHPJHP »

Hi RASHAD,

That is a good idea using an image as a frame (I really like the pin-up), but you may not have seen the changes in the latest version. A single image or even multiple images won't work anymore due to the various/unlimited shapes that can be applied, not to mention the area I'm writing to is the window itself. I think either drawing the frame or my preference of using regions would work better: https://msdn.microsoft.com/en-us/librar ... s.85).aspx

I'd be interested to hear from others as to the quality of the magnified image, whether they experience a flicker after the latest changes.
- the 2 pixel border (can be removed) may flicker at times, but I'm only concerned with feedback about the main image

NB*: I've tested the code using a BitBlt double buffer without a noticeable difference, but I'm also not seeing a flicker.
Last edited by JHPJHP on Sat Feb 21, 2015 9:25 pm, edited 2 times in total.
User avatar
BasicallyPure
Enthusiast
Enthusiast
Posts: 536
Joined: Thu Mar 24, 2011 12:40 am
Location: Iowa, USA

Re: Comic Book / Magnifying Glass

Post by BasicallyPure »

With your latest version of MagnifyingGlass I get this error message.

Image
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Comic Book / Magnifying Glass

Post by JHPJHP »

Hi BasicallyPure,

Thank you again for taking the time to test this and posting your results. I think I know why you were seeing a flicker before when I wasn't:

You may have Aero disabled or your video card doesn't support it? Can you confirm this please.

NB*: I realize this method in its current state is not viable as a magnifying tool in a production application, there are too many restrictions such as OS support and access to DWM. However I am hoping that it does provide others with some interesting code to work with and adapt to something more useful.
User avatar
BasicallyPure
Enthusiast
Enthusiast
Posts: 536
Joined: Thu Mar 24, 2011 12:40 am
Location: Iowa, USA

Re: Comic Book / Magnifying Glass

Post by BasicallyPure »

JHPJHP wrote:You may have Aero disabled or your video card doesn't support it? Can you confirm this please.
I did have Aero disabled.
It works after I enable Aero.
No flicker, image looks good.
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Comic Book / Magnifying Glass

Post by JHPJHP »

Thank you BasicallyPure, I'm glad we could figure this out.

-------------------------------------------------

Updated: MagnifyingGlass.pb
- found a better way to create a border (no flicker)
- optimized the code to work with the new change

NB*: Border is now static and cannot be removed.

-------------------------------------------------

Updated: MagnifyingGlass.pb
- added the option to include a handle
-- added 1 image: handle.bmp

The update is a basic variation of what RASHAD was kind enough to post.

NB*: The Procedure: AddMagnifyHandle is currently using simple logic to account for resizing, ratio and position.

-------------------------------------------------

Updated: MagnifyingGlass.pb
- added the option to use a pattern brush
-- added 1 image: steel.bmp

NB*: Update also includes some additional improvements not worth documenting.
Last edited by JHPJHP on Mon Feb 23, 2015 10:08 pm, edited 2 times in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Comic Book / Magnifying Glass

Post by JHPJHP »

Updated: MagnifyingGlass.pb
- replaced the handle image
- added / recoded additional options
-- #MAGNIFY_SIZE = 400
-- #MAGNIFY_HANDLE = "binaries/handle.bmp"
-- #MAGNIFY_PATTERN = "binaries/steel.bmp"
-- #MAGNIFY_COLOR = $033B03
-- #MAGNIFY_OUTLINE = #Gray
-- #MAGNIFY_SHOW = #MAGNIFY_SHOW_UNDER_WINDOW
-- #MAGNIFY_RATIO = #MAGNIFY_RATIO_FIT
-- #MAGNIFY_FRAME = #MAGNIFY_FRAME_ROUND_CORNERS

NOTE:
- set #MAGNIFY_HANDLE = #NULL$ to remove the handle
- set #MAGNIFY_PATTERN = #NULL$ to use #MAGNIFY_COLOR

NB*: #MAGNIFY_OUTLINE has been disabled for: #MAGNIFY_FRAME_ROUND due to a slower refresh rate with large curves.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Comic Book / Magnifying Glass

Post by JHPJHP »

Updated ComicBook.pb
- found an error that only showed when the debugger was enabled, now fixed
- improved the code slightly, nothing really noticeable

I just installed PureBasic v5.40 LTS Beta 9, and so far this was the only error I found across my Tricks 'n' Tips posts; which was a fault in the coding not the IDE.
- great job PB Team, thank you for your hard work and great product

--------------------------------------------------

If your interested in viewing images in a book-like format take a look at my other Tricks 'n' Tips post: Embed JS Framework into PureBasic.
- TurnJS_Create.pb, TurnJS_Double.pb ( TurnJS )
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Magnify & Book Effects

Post by Fangbeast »

JHPJHP, wish I had seen this a few years ago.

It occurred to me that it would come in very useful for my image database and my Home Inventory pictures.

Now I just have to wait for the cold weather to stop freezing me and my brain will kick in:):)
Amateur Radio, D-STAR/VK3HAF
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Magnify & Book & iPhone

Post by JHPJHP »

Hi Fangbeast,

Things get buried quickly, so many new posts.

The Comic Book example was based on a page-turn effect created by Michael Vogel: http://www.purebasic.fr/english/viewtop ... 88#p460888
Fangbeast wrote:JHPJHP, wish I had seen this a few years ago.
In light of your statement, I moved an example into this package from my Services, Stuff & Shellhook thread; also from a few years back.
- iPhoneIV (Image Viewer)

1. Press the iPhone button to switch between the two images.
2. Press the Spacebar to change orientation.
3. Press the Esc Key to exit the application.

NB*: Only two images have been loaded into the viewer to better demonstrate the orientation feature.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Magnify & Book & iPhone

Post by Fangbeast »

I've already downloaded your code and tried it and am happy. Don't have an iphone so not likely to try that one:):)
Amateur Radio, D-STAR/VK3HAF
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Magnify & Book & iPhone

Post by JHPJHP »

Hi Fangbeast,
Fangbeast wrote:I've already downloaded your code and tried it and am happy.
That is good to hear... Thank you for posting back.

Concerning the iPhone example, the name is misleading; iPhone in name only and shape of the window. Otherwise it's best described as a sliding images effect (carousel animation).

1. Press the iPhone button to switch between the two images.
2. Press the Spacebar to change orientation.
3. Press the Esc Key to exit the application.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Magnify & Book & iPhone

Post by Fangbeast »

Haven't been doing things for a while. Had an accident and am recovering.

Would you have an example for loading images off disk instead of a memory database?

I don't want to damage your code (until I recover, my brain isn't working) and I want to add your code to my home inventory program to view items.
Amateur Radio, D-STAR/VK3HAF
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Magnify & Book & iPhone

Post by JHPJHP »

Hi Fangbeast,

I've updated the ComicBook example to include a Procedure for loading images from a folder.
- #ARCHIVE_TYPE = 0 :: load images from database
- #ARCHIVE_TYPE = 1 :: load images from folder

Hope your recovery is going well.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Magnify & Book & iPhone

Post by Fangbeast »

Hope your recovery is going well.
Thanks for that update. Wen I had the accident, I didn't know my left rib was hurt as well so recovery is slow but I will get there.

And when the warmer weather is here, I hope my brain kicks in as well. It was -1 again last night.
Amateur Radio, D-STAR/VK3HAF
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: Book & Viewer & Magnify

Post by JHPJHP »

Updated (\Magnify_Glass\Magnify.pb:
- smoother image effect
- some minor code improvements
JHPJHP wrote:The script used to create the magnifying glass was taken from a comic book reader / editor I wrote awhile ago. The comic book images were resized to fit the screen. As the magnifying glass moved over the resized image, the original image was displayed within the glass area giving a magnified effect.
Image

------------------------------------

Updated (\Comic_Book\ComicBook.pb:
- some minor code improvements
Locked