Article View: news.software.readers
Article #256120--
From: Jeff-Relf.Me
Date: Sat, 09 Nov 2013 22:55
Date: Sat, 09 Nov 2013 22:55
136 lines
7021 bytes
7021 bytes
<PRE Style='White-Space: PRE !important; Font-Size: 18px !important;Font-Family: Menlo, monospace !important;'>Â
Here's the next thing in TV tech... and, eventually, PC tech:
4k, Ultra HD, UHD, 3840 ( 2 * 1920 ) x 2160 ( 2 * 1080 ).
ïŒ<A hRef='http://Jeff-Relf.Me/4k-UHD-.JPG'
target=_blank>Here</A>ïŒ is a 4k pic of a chapel.
Below, is ïŒ<A hRef='http://Jeff-Relf.Me/X.CPP'
target=_blank>some code</A>ïŒ* I use to zoom in on parts of it.
[ *: Visual C++, Visual Studio 2010 ]
In ïŒ<A hRef='http://Jeff-Relf.Me/X.HTM'
target=_blank>my "browser"</A>ïŒ...
To zoomâ
in on something, wheel forward on it or Leftâ
Click;
to zoomâ
out, wheel back or Rightâ
Click.
To Zoom, the code places a rectangle within the image.
The rectangle has the same hight/width ratio as the dipaly port,
and it's FULLY bound to the contents of the image ( scooting, as needed ),
at the click location, at the desired zoom level.
int imgOnce ; LnP imgDir ;
int imgSh( LnP FileName ) {
HDC DC ; int Y_Top, idxSzïŒ ; const int mxZ = 22 ; const float e = 2.71828 ;
LnP mxNam ; Gdiplus::Image Img( FileName );
float rv2, rv = WinH, WinH, W_imgâ°, H_imgâ°, X_Mouse_in_img, Y_Mouse_in_img,
Wâ±H, SzïŒWide, SzïŒTall, SzïŒ, X_in_img, Y_in_img, W_in_img, H_in_img ;
// This ïŒ<A hRef='https://en.wikipedia.org/wiki/LIFO_%28computing%29#Definition'
target=_blank>FILO stack</A>ïŒ of rectangles; controls where/how to zoom.
struct zmT { float X_in_img, Y_in_img, W_in_img, H_in_img ; };
zmT Zmâ°[ mxZ ];
Y_Top = CharH * RowsTop, WinH = rv - Y_Top;
mxNam = FileName + ER( 0, szStr( FileName ) - 33 );
if ( Img.GetLastStatus() != Gdiplus::Ok ) {
// Bad Image.
Notice( L"! ? %s â± %s ", mxNam, imgDir ); goto Next ; }
// Get the dimensions of the image;
// zoom it in or out, so it fits the view port.
idxSzïŒ = 0, X_in_img = Y_in_img = 0 ;
W_in_img = W_imgâ° = Img.GetWidth(), H_in_img = H_imgâ° = Img.GetHeight();
Wâ±H = WinW / WinH, SzïŒTall = WinW / W_in_img, SzïŒWide = WinH / H_in_img ;
Notice( L"%d%% â± %s â± %s", Round( 100 * W_in_img / WinW ), mxNam, imgDir );
goto Draw ;
Wait:
if ( PrintReq = WaitngForClick = 1, Read(), Canceled ) goto Fin ;
if ( OnKeyUp && C == 13 ) {
// User hit the ENTER key; go to the next image.
Next:
if ( !imgOnce )
// "imgOnce" ( one image only ) is false;
// return "true", to fetch the next image.
return 1 ;
Fin:
// User is done viewing the image; clear the screen.
// Set "imgOnce" to false ( the default ).
Notice(), ClearScreen, CD( Xâ
Dir ); return imgOnce = 0 ; }
if ( OnScroll > 0 || OnRU ) {
// User wheeled back or Rightâ
Clicked.
// Zoom out; pop the previous rectangle off the stack.
SzïŒ /= e, idxSzïŒ = ER( idxSzïŒ - 1, 0 ); zmT &Zm = Zmâ°[ idxSzïŒ ];
X_in_img = Zm.X_in_img, Y_in_img = Zm.Y_in_img ;
W_in_img = Zm.W_in_img, H_in_img = Zm.H_in_img ; goto Draw ; }
if ( OnScroll >= 0 && !OnLU )
// User didn't wheel forward, or Leftâ
Click ( OnLU ).
// Wait for the User to do something.
goto Wait ;
// Place the userâ
selected rectangle, zoomed down, in the image.
X_Mouse_in_img = X_in_img + W_in_img * Bound( X_Mouse - X_to, 0, W_to ) / W_to ;
Y_Mouse_in_img = Y_in_img + H_in_img * Bound( Y_Mouse - Y_to, 0, H_to ) / H_to ;
W_in_img = er( W_imgâ°, W_imgâ° / SzïŒ ), H_in_img = er( H_imgâ°, W_in_img / Wâ±H ), W_in_img = H_in_img * Wâ±H ;
X_in_img = Bound( X_Mouse_in_img - W_in_img/2, 0., W_imgâ° - W_in_img );
Y_in_img = Bound( Y_Mouse_in_img - H_in_img/2, 0., H_imgâ° - H_in_img );
SzïŒ *= e, idxSzïŒ = er( idxSzïŒ + 1, mxZ - 1 );
Draw:
// Draw the image; push the zoomâ
level onto the stack.
{ zmT &Zm = Zmâ°[ idxSzïŒ ]; Zm.X_in_img = X_in_img, Zm.Y_in_img = Y_in_img, Zm.W_in_img = W_in_img, Zm.H_in_img = H_in_img ; }
if ( idxSzïŒ )
// Zooming in; use the entire display port, WinW x WinH.
X_to = 0, Y_to = Y_Top, W_to = WinW, H_to = WinH ;
else
// Return to the intial display, fit the image to the display port.
SzïŒ = er( SzïŒWide, SzïŒTall ), W_to = W_in_img * SzïŒ,
H_to = H_in_img * SzïŒ, X_to = ( WinW - W_to )/2, Y_to = Y_Top + ( WinH - H_to )/2,
SzïŒ = fabs( SzïŒWide - SzïŒTall ) < .1 ? e : 1 ;
Trash( imgSur ), NewSur( imgSur, W_to, H_to ), imgSur->GetDC( &DC );
Gdiplus::Graphics Plus( DC ); Gdiplus::Rect recTo( 0, 0, (int)W_to, (int)H_to );
Plus.DrawImage( &Img, recTo, (int)X_in_img, (int)Y_in_img, (int)W_in_img, (int)H_in_img, Gdiplus::UnitPixel );
imgSur->ReleaseDC( DC );
if ( Ln.PP < Ln.BB || !Ln.PP || !*Ln.PP || **Ln.PP != imgâ
Ch )
// "imgâ
Ch" ( to display an image ) isn't in the console, add it.
Sh( L"%c", imgâ
Ch );
// Now, the image is displayed; wait on the user.
goto Wait ; }
#define JPGsââ { \
/* CD to "Path_Showing" ( the sub directory ) */ \
if ( CD( Path_Showing ), !JPGs() ) \
/* Done dipalying images ( in the folder ). */ \
goto WinMain ; }
int JPGs() {
int rv ; LnP FileName ; wchar_t prev_FileNam[400]; DirA
if ( *prev_FileNam = 0, !DirI( L"*.jp*", 0 ) )
// No .JPG files in the folder.
return 1 ;
LOOP {
// Get the next .JPG file in the folder;
if ( rv = !BoDir, BoDir = 0, rv && _Failed_To_Get_Another_File( &FF_Rec, FF_List ) )
// No more images, exit the loop.
break;
if ( Is_a_Dir )
// Skip subâ
subâ
folders.
continue ;
Notice(), Read(), FileName = FF_Rec.cFileName ;
Delete_File( prev_FileNam ), Str( prev_FileNam, L"%s", FileName );
if ( !imgSh( FileName ) )
// User is done viewing images.
return 0 ; }
Delete_File( prev_FileNam ); return 1; }
Technical Details
Message-ID:
<Jeff-Relf.Me@Nov.9{14.55.Seattle.2013}>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.free.newsservers.20150605.mbox.gz!border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.bnb-lp.com!news.glorb.com!news-spur1.glorb.com!newsread.glorb.com!.POSTED!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <Jeff-Relf.Me@Nov.9{14.55.Seattle.2013}>
Subject: --
Date: Sat, 09 Nov 2013 22:55:37 +0000
From: Jeff-Relf.Me <@.>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.free.newsservers.20150605.mbox.gz!border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.bnb-lp.com!news.glorb.com!news-spur1.glorb.com!newsread.glorb.com!.POSTED!not-for-mail
Newsgroups: news.software.readers, alt.free.newsservers, comp.os.linux.advocacy, sci.physics
sci.physics
Organization: Glorb Internet Services, http://www.glorb.com
Lines: 136
NNTP-Posting-Host: XJGH+5GM8EvggnDfgIBqtQ.597.posting.glorb.com
Content-Type: Text/HTML; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Complaints-To: abuse@glorb.com
NNTP-Posting-Date: Sat, 9 Nov 2013 22:55:14 +0000 (UTC)
User-Agent: Jeff-Relf.Me/X.HTM
X-Notice: Scanned by Mr. Bill
X-Original-Bytes: 6913