🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
1 messages
1 total messages Started by Jeff-Relf.Me Sat, 09 Nov 2013 22:55
--
#256120
Author: Jeff-Relf.Me
Date: Sat, 09 Nov 2013 22:55
136 lines
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  &amp;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  &amp;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( &amp;DC );
  Gdiplus::Graphics  Plus( DC ); Gdiplus::Rect  recTo( 0, 0, (int)W_to, (int)H_to );
  Plus.DrawImage( &amp;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( &amp;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;  }
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads