Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.apple2.programmer > #1529

Re: Displaying BSAVE Double Hi-Res Graphics (DHGR) Image Files in AppleSoft BASIC

From "Bill Buckels" <bbuckels@mts.net>
Newsgroups comp.sys.apple2.programmer
Subject Re: Displaying BSAVE Double Hi-Res Graphics (DHGR) Image Files in AppleSoft BASIC
Date 2015-02-26 20:35 -0600
Organization Aioe.org NNTP Server
Message-ID <mcol68$shg$1@speranza.aioe.org> (permalink)
References <marm5t$1ba$1@speranza.aioe.org> <ecb64098-b23f-43bd-9bbe-698e002f2c0d@googlegroups.com> <mcojpe$q7e$1@speranza.aioe.org>

Show all headers | View raw


"Bill Buckels" <bbuckels@mts.net> wrote:
>You might also want to take a look at the following links:

<snip>

http://www.appleoldies.ca/bmp2dhr/

Optional Usage: "b2d input.bmp L (or DL) options"
For Color LGR or DLGR Full Screen or Mixed Screen (option "TOP") Output.

Command-line switches "L" and "DL"

if (cmpstr("DL", (char *)&wordptr[0]) == SUCCESS) {
/* DLGR output */
loresoutput = 1;
break;
}

case 'L':

/* LGR output */
lores = loresoutput = 1;
break;

/* color LGR and DLGR */
/* all lo-res and double lo-res input is resized to one of 2 -
sizes of input file:

80 x 48 or 80 x 40

the input file is then processed as a "small" double hi-res
image. since the color palette is exactly the same, the same
rendering options are available.

after processing the double hi-res output buffer is converted to
lo-res or double lo-res formatting and saved as Apple II native
LGR or DLGR output.

*/

for LGR use 40 x 48, for DLGR use 80 x 48 etc.

Although the Apple II offers Lo-Res Graphics (LGR) and Double Lo-Res 
Graphics (DLGR), these graphics modes are very coarse and really not very 
suitable for displaying converted content from continuous palette images. 
The converted output from these generally looks like enlarged icons or 
thumbnail images. For the most part LGR and DLGR input files converted from 
pixel-art BMPs (created by methods like coloring converted "Old PrintShop" 
or "Mini-Pix" files) will work better.

/* LGR and DLGR only */
sshort ValidLoResSizeRange()
{
 sshort status = INVALID;

 /* monochrome input files are not accepted for LGR or DLGR conversion */
 if (bmi.biBitCount != 1) {

    /* http://en.wikipedia.org/wiki/Windowbox_(film) - cropped (clipped) 
images */
    /* restricted to a reasonable number of sizes that make sense to me */
    /* additional scaling can be done outside of here */
    /* for lores verbatim fullscreen output use 40 x 48 input files */
    /* for double lores verbatim fullscreen output use 80 x 48 input files 
*/
    /* for mixed text and graphics mode output of the above is automatic 
with
    input files of 40 lines, and by default clips the bottom 8 lines with
    input files of 48 lines... and optionally the windowbox can be shifted
    downwards by 0-8 lines when justify option JL is used.

    larger sizes behave similarly. scaling of larger sizes uses pixel merge
    to combine pixels and scanlines so detail loss will occur. sizes like
    88 x 52, 176 x 104 and 320 x 200 also provide optional windowbox 
shifting for
    fullscreen output as well as for mixed text and graphics output. these
    over-scanned sizes are centered on the display by default. over-scanned 
sizes
    use the same nominal resolution as pre-scaled sizes,

    640 x 480 (fullscreen) and 640 x 400 (mixed text and graphics) is the 
only
    "Classic Size" supported for LGR and DLGR

    during processing, in order to lever the same routines used by HGR and 
DHGR,
    half-scaling is provided for LGR as a "second level" of scaling. all 
output
    is restricted to one of 4 sizes:

    LGR - 40 x 40 and 40 x 48
    DLGR - 80 x 40 and 80 x 48

    LGR and DLGR image fragments are not supported for this version of 
Bmp2DHR

    */

  switch(bmpwidth) {

  case 40:  lores = 1; /* verbatim 1:1 lgr only - nominal size 40 x 48 */
  case 80:
      /* verbatim 1:1 for dlgr - nominal size 80 x 48 */
      /* 2:1 scaled for lgr */
      if (bmpheight == 40 || bmpheight == 48) status = SUCCESS;
      else break;
      jxoffset = 0; /* windowbox in vertical axis only */
      if (bmpheight == 40) {
       /* mixed text and graphics */
       /* 40 x 40 and 80 x 40 - windowbox not required */
       appletop = 1;
       justify = jyoffset = 0;
       break;
      }
      if (appletop == 1) {
       /* mixed text and graphics */
       /* 40 x 48 and 80 x 48 - windowbox required */
       /* top justified if not otherwise specified */
       if (justify == 1 && (jyoffset > -1 || jyoffset < 9)) {
        jyoffset = 8 - jyoffset;
        break;
       }
       jyoffset = 8;
       justify = 1;

      }
      else {
       /* fullscreen */
       /* 40 x 48 and 80 x 48 */
       justify = jyoffset = 0;

      }
      break;

  case 88:  /* the next two input widths (88 and 176) are processed as 
over-scanned images */
      /* these originate from clipped BMP format "MiniPix" conversions */
      /* saved in Windows Paint as "old" and "new" printshop "pastes" from 
ClipShop in
      small-copy (single-scaled) or regular copy (double-scaled) format. */

      if (bmpheight != 52) break;
      status = SUCCESS;  /* verbatim for dlgr - nominal size 80 x 48 */
      if (jxoffset < 0 || jxoffset > 8) {
       jxoffset = 4; /* centre */
      }
      if (appletop == 1) { /* mixed text and graphics - dlgr windowbox 80 x 
40 */
       if (justify == 1 && (jyoffset > -1 && jyoffset < 13)) jyoffset = 12 - 
jyoffset;
       else jyoffset = 10;
       justify = 1;
       break;
      }
      justify = 1;
      if (jyoffset < 0 || jyoffset > 4) {
       jyoffset = 2; /* centre */
      }
      break;
  case 176: if (bmpheight != 104) break;
      status = SUCCESS; /* dlgr double-scaled - nominal size 160 x 96 */
      if (jxoffset < 0 || jxoffset > 16) {
       jxoffset = 8; /* centre */
      }
      if (appletop == 1) { /* mixed text and graphics - dlgr windowbox 160 x 
80 */
       if (justify == 1 && (jyoffset > -1 && jyoffset < 25)) jyoffset = 24 - 
jyoffset;
       else jyoffset = 20;
       justify = 1;
       break;
      }
      justify = 1;
      if (jyoffset < 0 || jyoffset > 8) {
       jyoffset = 4; /* centre */
      }
      break;
  case 160: /* nominal size 160 x 96 */
      /* 2:2 scaled for dlgr, 4:2 scaled for lgr */
      if (bmpheight == 80 || bmpheight == 96) status = SUCCESS;
      else break;
      jxoffset = 0;
      if (bmpheight == 80) {
       /* 160 x 80 - mixed text and graphics */
       appletop = 1;
       justify = jyoffset = 0;
       break;
      }
      if (appletop == 1) {
       /* mixed text and graphics */
       /* 160 x 96 - windowbox required */
       /* top justified if not otherwise specified */
       if (justify == 1 && (jyoffset > -1 || jyoffset < 17)) {
        jyoffset = 16 - jyoffset;
        break;
       }
       jyoffset = 16;
       justify = 1;

      }
      else {
       /* fullscreen */
       /* 160 x 96 */
       justify = jyoffset = 0;

      }
      break;
  case 320: /* nominal size 320 x 192 */
      /* 4:4 scaled for dlgr, 8:4 scaled for lgr */
      if (bmpheight == 160 || bmpheight == 192 || bmpheight == 200) {
       status = SUCCESS;
       jxoffset = 0; /* vertical scaling of mixed text and graphics only */
       if (bmpheight == 160) {
        appletop = 1;
        justify = jyoffset = 0;
        break;
       }
       if (bmpheight == 192) {
        if (appletop == 1) {
         if (justify == 1 && (jyoffset > -1 && jyoffset < 33)) jyoffset = 
32 - jyoffset;
         else jyoffset = 32;
         justify = 1;
         break;
        }
        justify = jyoffset = 0;
        break;
       }
       /* 320 x 200 */
       /* centre in frame by default */
       if (appletop == 1) {
        if (justify == 1 && (jyoffset > -1 && jyoffset < 41)) jyoffset = 
40 - jyoffset;
        else jyoffset = 36;
        justify = 1;
        break;
       }
       if (justify == 1 && (jyoffset > -1 && jyoffset < 9)) jyoffset = 8 - 
jyoffset;
       else jyoffset = 4;
       justify = 1;
      }
      break;
  case 560: /* "Classic" full-screen conversion of pre-scaled 560 x 384 
input */
      /* "Classic" mixed text and graphics screen conversion of pre-scaled
      560 x 384 full-screen or 560 x 320 cropped input */
      /* 7:8 scaled for dlgr, 14:8 scaled for lgr */
      if (bmpheight == 320 || bmpheight == 384) status = SUCCESS;
      else break;
      jxoffset = 0;
      if (bmpheight == 320) {
       /* mixed text and graphics */
       appletop = 1;
       justify = jyoffset = 0;
       break;
      }
      if (appletop == 1) {
      /* mixed text and graphics */
      if (justify == 1 && (jyoffset > -1 && jyoffset < 65)) jyoffset = 64 - 
jyoffset;
      else jyoffset = 64;
      justify = 1;
      }
      else {
      /* fullscreen */
      justify = jyoffset = 0;
      }
      break;
  case 640: /* "Classic" full-screen conversion of 640 x 480 square pixeled 
input */
      /* "Classic" mixed text and graphics screen conversion of square 
pixeled
       640 x 480 full-screen or 640 x 400 cropped input */
      /* 8:10 scaled for dlgr, 16:10 scaled for dlgr */
      if (bmpheight == 480 || bmpheight == 400) status = SUCCESS;
      else break;
      jxoffset = 0;
      if (bmpheight == 400) {
       /* mixed text and graphics */
       appletop = 1;
       justify = jyoffset = 0;
       break;
      }
      if (appletop == 1) {
      /* mixed text and graphics */
      if (justify == 1 && (jyoffset > -1 && jyoffset < 81)) jyoffset = 80 - 
jyoffset;
      else jyoffset = 64;
      justify = 1;
      }
      else {
      /* fullscreen */
      justify = jyoffset = 0;
      }
      break;
  }
 }

 return status;
}

Back to comp.sys.apple2.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Displaying BSAVE Double Hi-Res Graphics (DHGR) Image Files in AppleSoft BASIC "Bill Buckels" <bbuckels@mts.net> - 2015-02-03 17:38 -0600
  Re: Displaying BSAVE Double Hi-Res Graphics (DHGR) Image Files in AppleSoft BASIC laseractiveguy@gmail.com - 2015-02-26 01:02 -0800
    Re: Displaying BSAVE Double Hi-Res Graphics (DHGR) Image Files in AppleSoft BASIC "Bill Buckels" <bbuckels@mts.net> - 2015-02-26 20:11 -0600
      Re: Displaying BSAVE Double Hi-Res Graphics (DHGR) Image Files in AppleSoft BASIC "Bill Buckels" <bbuckels@mts.net> - 2015-02-26 20:35 -0600
        Re: Displaying BSAVE Double Hi-Res Graphics (DHGR) Image Files in AppleSoft BASIC "Bill Buckels" <bbuckels@mts.net> - 2015-02-26 20:52 -0600

csiph-web