Phoebus Dokos wrote:

> You could also get BMP2SCR from Malcolm and use it in reverse
(trivial to
> do so and from the quick look I gave to your code you're on the
right
> track).
Just had a quick look (it's on disk GE104 in my PD library) . However,
it doesn't explain the file structure except how to check it's 24 bit
and picture size. But it does show how to do the approximation of 24
bit colour to 16 bit QL colour (i.e. how to convert 8 bit RGB
component to 5 or 6 bit GD2 colour components - simply lop off the
extra info, you then simply get coarser steps of colour, so instead of
values 0-31 for a bit GD2 colour you get 0-255 step 8 in 24-bit
colour). A bit mind bending for a simpleton like me, but I'll get
there ;-)

> And (I don't know if you mentioned it in your message as I really
didn't
> read it through, just a quick look) always remember that the lines
on the
> bmp are stored upside down :-)
Err, yes, that did throw me a bit when I had a first crack at the
program. You realise your code works then it slowly sinks in that the
picture's upside down!

> I do have a full program ready that does that, however you're
killing
> yourself with no reason.
> Just press Print Screen while you're running QPC and then paste it
> in your favourite graphics editor :-)
>
> Presto you're screen capture is complete :-)

Point taken about using PrintScreen etc, but I wanted to write a
"simple" piece of code to insert
in one of the Launchpad utilities, hence the reason for "killing
myself". With some help from Geoff Wicks, I got the Windows character
translations (as opposed to DOS ones). With (as yet) no GD2 screen
dumps, the best interim option seemed to be to allow for export of QL
GD2 graphics to PC formats and BMP seemed the easiest to get going as
I didn't have to wrestle with compression.

I want to try to look at the possibility of getting a PC program to do
the printing, to see if the QPC_EXEC command could be persuaded to
fire up a Windows or DOS program, load a file and make it print since
Marcel has kindly put the abilty to fire up a PC program in QPC2.
After all, I'm not asking the PC to do anything File Info II can't do
for a QL program :o)

I do already use PrintScreen but in addition to the file exporting I
mentioned, I can also write a batch converter for Launchpad which can
be left to get on with it in its own time (overnight perhaps) rather
than have to do all that cutting and pasting manually.


Marcel Kilgus wrote:
> > blue=8*(PEEK(addr)&&31)
> > red =PEEK(addr+1)&&248
>
> Those are 5 bit, i.e. from 0 to 31.
>
> > green=(PEEK(addr)&&224)||((PEEK(addr+1)&&7)*4)
>                                              *8
> This is 6 bit, i.e. from 0 to 63.
>
> Conversion to 8 bit is needed, of course.
>
> > The .BMP file equivalent long word would then be built as follows:
> > POKE bmp_addr,blue
> > POKE bmp_addr+1,green
> > POKE bmp_addr+2,red
> > POKE bmp_addr+3,0 : rem unused but must be 0
>
> IIRC BMP data is 24 bit, i.e. without the 0.
There seems to be two formats, RGB Quad 3.0 using 4 bytes (the fourth
of which seems to have to be reset, presumably so software can
manipulate the 32 bits without having stray bits floating around to
corrupt the values) and RGB 2.x which uses 3 bytes per pixel, which
seems hard to manipulate. Although the 24 bits-of-32 seems wasteful.
it's easier to manipulate.

>
> > QL_bytes = pixel_width*pixel_height : REMark width should be even?
>
> Every BMP single screen line must be padded to a 4 byte boundary.
Ah yes, it does say that in my notes, I just missed it. But if I use
the 32 bit format this would just happen anyway.

Thanks Marcel, Phoebus and others who helped me with this.

Although there are programs for the QL which do the conversion I want
to some degree, I wanted to write my own fairly simple code (speed not
too
important) to insert in my own programs.

I downloaded some free docs from the web on various PC file formats -
BMP, GIF, JPG, PNG, TIF etc - if anyone wants them they're on disks
GE145 and GE146 in the library. If there's enough interest I could put
them onto my websites for download (might help stimulate development
of GD2 graphics-ware). If I do come upwith a reasonable SBASIC program
to do the BMP conversion I might print it in QL Today as a follow up
to my recent GD2 article, if it wouldn't be hypocrisy having an
article about a Windoze file format!

--
Dilwyn Jones



Reply via email to