Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.apple2.programmer > #1503 > unrolled thread
| Started by | "Bill Buckels" <bbuckels@mts.net> |
|---|---|
| First post | 2015-02-03 17:38 -0600 |
| Last post | 2015-02-26 20:52 -0600 |
| Articles | 5 — 2 participants |
Back to article view | Back to comp.sys.apple2.programmer
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
| From | "Bill Buckels" <bbuckels@mts.net> |
|---|---|
| Date | 2015-02-03 17:38 -0600 |
| Subject | Displaying BSAVE Double Hi-Res Graphics (DHGR) Image Files in AppleSoft BASIC |
| Message-ID | <marm5t$1ba$1@speranza.aioe.org> |
More DHGR Mischief! http://www.appleoldies.ca/bmp2dhr/basic/ This article is about loading and displaying Apple II DHGR BSAVE graphics files in Apple II AppleSoft BASIC programs and includes programming examples and background information. Disk Images with examples and sample DHGR images: http://www.appleoldies.ca/bmp2dhr/basicdhgr.zip All the best, Bill Buckels
[toc] | [next] | [standalone]
| From | laseractiveguy@gmail.com |
|---|---|
| Date | 2015-02-26 01:02 -0800 |
| Message-ID | <ecb64098-b23f-43bd-9bbe-698e002f2c0d@googlegroups.com> |
| In reply to | #1503 |
I might be an idiot, but I honestly couldn't get this to work... I had to write my own graphics program, this is a 40x40 lo-res converter... there most likely will be a higher res version when the need arises. It converts the image directly on the APPLE II itself... can use any format BMP/JPG/PNG ect... so easy it converts it in a mere few clicks... Check out the video, link for download included at the video.... https://www.youtube.com/watch?v=0P3b9h_K7_4&list=UUoN7gbsWcuzU5pjWiOFdxMg -Tom at Naspite Labs > http://www.appleoldies.ca/bmp2dhr/basicdhgr.zip > > All the best, > > Bill Buckels
[toc] | [prev] | [next] | [standalone]
| From | "Bill Buckels" <bbuckels@mts.net> |
|---|---|
| Date | 2015-02-26 20:11 -0600 |
| Message-ID | <mcojpe$q7e$1@speranza.aioe.org> |
| In reply to | #1525 |
<laseractiveguy@gmail.com> wrote: >I might be an idiot, but I honestly couldn't get this to work... Since all my code works and comes with source I really don't know what else to say except that not everyone can use command line utilities or read and write C code. The source code is pretty self-explanatory. You might also want to take a look at the following links: http://www.appleoldies.ca/azgraphics33/UsingBMP2LOToCreateApple2_DLOGRFiles_Dec2012.pdf http://www.appleoldies.ca/graphics/lgr/LORES_DOUBLELORES_TEXT_AWINDLO_TUTORIAL.pdf http://www.aztecmuseum.ca/AppleWin_LGR_DLGR_ScreenGrabs_2013.pdf http://www.appleoldies.ca/cc65/docs/dlgr/dlodemo.pdf http://www.appleoldies.ca/cc65/docs/dlgr/dloshow.pdf >I had to write my own graphics program, this is a 40x40 lo-res converter... >there most likely will be a higher res version when the need arises. Well, you didn't have to... but whatever makes you happy. >It converts the image directly on the APPLE II itself... can use any format >BMP/JPG/PNG ect... so easy it converts it in a mere few clicks... Mine converts without any clicks, etc. >Check out the video, link for download included at the video.... I cross-posted the video along with your links into the FaceBook group. Bill
[toc] | [prev] | [next] | [standalone]
| From | "Bill Buckels" <bbuckels@mts.net> |
|---|---|
| Date | 2015-02-26 20:35 -0600 |
| Message-ID | <mcol68$shg$1@speranza.aioe.org> |
| In reply to | #1528 |
"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;
}
[toc] | [prev] | [next] | [standalone]
| From | "Bill Buckels" <bbuckels@mts.net> |
|---|---|
| Date | 2015-02-26 20:52 -0600 |
| Message-ID | <mcom5h$tvs$1@speranza.aioe.org> |
| In reply to | #1529 |
"Bill Buckels" <bbuckels@mts.net> wrote:
<smip>
Here's the LGR and DLGR save options from Bmp2DHR. I won't post any more
source. I really don't expect anyone who can't use the command line to
understand this but for those who do, youi can see that Lo-Res and Double
Lo-Res conversion is pretty much fully supported in Bmp2DHR with most of the
options for HGR and DHGR conversion.
2-formats are available: raster-oriented or optionally BSAVE.
As far as a BSAVE Lo-Res or Double Lo-Res "
/* these cannot be loaded in a ProDOS BASIC program and should probably not
be loaded in a C program */
/* they are arguably unsafe to load even in DOS 3.3 since they clobber the
text screen holes */
Here's the save function...
/* save 2 output files */
int savelofragment()
{
FILE *fp;
unsigned char outfile[MAXF], temp, remap;
int x,y,x2,y2, offset;
/* raster files - single file output */
if (applesoft == 0) {
/* save single lo-res and double lo-res */
/* save raster images of 48 or 40 scanlines
(full graphics or mixed text and graphics) */
if (lores == 1) {
if (appletop == 1)
sprintf(outfile,"%s.STO",hgrwork);
else
sprintf(outfile,"%s.SLO",hgrwork);
}
else {
if (appletop == 1)
sprintf(outfile,"%s.DTO",hgrwork);
else
sprintf(outfile,"%s.DLO",hgrwork);
}
if (tags == 1) strcat(outfile,"#060400");
fp = fopen(outfile,"wb");
if (NULL == fp)return INVALID;
/* On the double lo res display each byte in
high memory is interleaved with a byte in low memory
in the interests of efficiency I am saving and loading
the interleaf on a scanline by scanline basis.
*/
memset(hgrbuf,0,LORAGSIZE);
for (y = 0; y< 48; y++) {
if (appletop == 1 && y > 39)break;
y2 = y;
/* first 40 bytes goes to auxilliary memory (even pixels) */
for (x = 0; x < 40; x++) {
x2 = (x*2);
remap = dhrgetpixel(x2,y2);
temp = dloauxcolor[remap];
setlopixel(temp,x,y,1);
}
/* followed by the interleaf (odd pixels)
next 40 bytes goes to main memory */
for (x = 0; x < 40; x++) {
x2 = (x*2) + 1;
temp = dhrgetpixel(x2,y2);
setlopixel(temp,x+40,y,1);
}
}
if (lores == 1) {
fputc(40,fp); /* bytes */
if (appletop == 1) fputc(20,fp);
else fputc(24,fp);
for (y = 0; y < 24; y++) {
if (appletop == 1 && y > 19)break;
offset = (y * 80)+40;
fwrite((unsigned char *)&hgrbuf[offset],1,40,fp);
}
}
else {
fputc(80,fp); /* bytes */
if (appletop == 1) {
fputc(20,fp); /* bytes (rasters / 2) */
fwrite(hgrbuf,1,LOTOPSIZE,fp);
}
else {
fputc(24,fp); /* bytes (rasters / 2) */
fwrite(hgrbuf,1,LORAGSIZE,fp);
}
}
fclose(fp);
printf("%s Saved!",outfile);
}
else {
/* bsaved images */
/* 2 files for double lo-res */
/* one file for lo-res */
/* these cannot be loaded in a ProDOS BASIC program and should
probably not be loaded in a C program */
/* they are arguably unsafe to load even in DOS 3.3
since they clobber the text screen holes */
/* for double lo-res the bsaved images are split into two files
the first file is loaded into aux mem
*/
if (lores == 0) {
sprintf(outfile,"%s.DL1",hgrwork);
if (tags == 1) strcat(outfile,"#060400");
fp = fopen(outfile,"wb");
if (NULL == fp)return INVALID;
memset(hgrbuf,0,LOBINSIZE);
for (y = 0; y< 48; y++) {
y2 = y;
for (x = 0; x < 40; x++) {
x2 = (x*2);
remap = dhrgetpixel(x2,y2);
temp = dloauxcolor[remap];
setlopixel(temp,x,y,0);
}
}
fwrite(hgrbuf,1,LOBINSIZE,fp);
fclose(fp);
printf("%s Saved!",outfile);
}
/*
for single lo res only 1 file is needed
for double lo res the second file is loaded into main mem
*/
if (lores == 1)
sprintf(outfile,"%s.SL2",hgrwork);
else
sprintf(outfile,"%s.DL2",hgrwork);
if (tags == 1) strcat(outfile,"#060400");
fp = fopen(outfile,"wb");
if (NULL == fp)return INVALID;
memset(hgrbuf,0,LOBINSIZE);
for (y = 0; y< 48; y++) {
y2 = y;
for (x = 0; x < 40; x++) {
x2 = (x*2) + 1;
temp = dhrgetpixel(x2,y2);
setlopixel(temp,x,y,0);
}
}
fwrite(hgrbuf,1,LOBINSIZE,fp);
fclose(fp);
printf("%s Saved!",outfile);
}
return SUCCESS;
}
[toc] | [prev] | [standalone]
Back to top | Article view | comp.sys.apple2.programmer
csiph-web