Qbasicnews.com
April 06, 2020, 10:43:46 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: screen to bitmaps  (Read 2726 times)
andy
Senior Member
**
Posts: 175



WWW
« on: October 09, 2003, 09:06:15 AM »

Look at this program I wrote last night, try it and tell me what you think

Quote
CLS
SCREEN 13

PRINT "Input start co-ordinate of x"
INPUT startx
PRINT "Input start co-ordinate of y"
INPUT starty
PRINT "Input end co-ordinate of x"
INPUT endx
PRINT "Input end co-ordinate of y"
INPUT endy
PRINT "Input file to save to, this will be saved in your qbasic folder, unless you specify a path"
INPUT file$
PRINT "If all of the above details are correct, press y else press n"
DO
khb$ = INKEY$
IF khb$ = "n" THEN GOTO 100
IF khb$ = "N" THEN GOTO 100
IF khb$ = "y" THEN GOTO 50
IF khb$ = "Y" THEN GOTO 50
LOOP
50 CLS

'draw picture here or get a gif with a loader etc.

FOR y = starty TO endy
PRINT #1, ""
PRINT #1, "DATA";
FOR x = startx TO endx
PRINT #1, POINT(x, y);
IF x <> endx THEN
PRINT #1, ",";
END IF
NEXT
NEXT
CLOSE #1
100
END


Bear in mind, that this is the first time I have ever used point and print #1
Logged

eminiscing about trapezoids in conjunction with stratospherical parabolas:

No questions asked.

www.stickskate.com
potato
Ancient QBer
****
Posts: 409



WWW
« Reply #1 on: October 09, 2003, 04:27:16 PM »

NB - you know this program ONLY captures the color of the pixel, not the coordinates? Practically useless.

I made a more useful, yet similar program recently, despite its inefficiency. It writes the relative X coordinate, then Y coordinate, then the color of the current pixel to a file (then next one, from a starting and ending box). When it loads, it draws at any X, Y, with color.

Rather than quitting the program at the end or if you say "N", try restarting it. Also, replace the two commands "y" "Y" with UCASE$(khb$), saves space

Your program erases the current screen and then draws the image. In order to capture the area you want, you'd have to know the exact pixel coordinates for start and end.

Maybe you should buffer the image, so you can redraw it quickly and add a selection box for the area you're cutting out.

Good start for a practice program with print #1, though.
Logged

ammit potato!
andy
Senior Member
**
Posts: 175



WWW
« Reply #2 on: October 10, 2003, 06:57:19 AM »

Thanks, but does it matter if the exact co-ordinates are capture. It writes the data statements to another file, and when you use that it puts the image in the top left, then you could use the get and put statements to place it where you want. I will include a targeting box, and also my new version writes the read and pset commands, etc in automatically.
Logged

eminiscing about trapezoids in conjunction with stratospherical parabolas:

No questions asked.

www.stickskate.com
TheBigBasicQ
*/-\*
*****
Posts: 4550



WWW
« Reply #3 on: October 10, 2003, 02:15:39 PM »

if you just want to capture the image on the screen. Use BSAVE and BLOAD.
Logged
potato
Ancient QBer
****
Posts: 409



WWW
« Reply #4 on: October 10, 2003, 04:40:44 PM »

Quote from: "andy"
Thanks, but does it matter if the exact co-ordinates are capture. It writes the data statements to another file, and when you use that it puts the image in the top left, then you could use the get and put statements to place it where you want. I will include a targeting box, and also my new version writes the read and pset commands, etc in automatically.


I see what you're doing now... still, don't need the PRINT #1, "DATA";
And you're right, the X, Y coords are unneccesary in the file, as you can just pass them to a subroutine.

Quote from: "TheBigBasicQ"
if you just want to capture the image on the screen. Use BSAVE and BLOAD.


What if he's using the ungiven load subroutine to create a transparent image? Concerning disk space, this is more effective than blitting, since you can just NOT draw a certain color.
IE he could have his load subrouting not plot a pixel when the loaded color is 255
Logged

ammit potato!
TheBigBasicQ
*/-\*
*****
Posts: 4550



WWW
« Reply #5 on: October 11, 2003, 10:31:38 AM »

Hmm...In that case he can use Future.Library. Here is an algo:

To save the image:
1. Draw the image on the screen.
2. Note the width and height.
3. Use Future.Snapshot to save the screen to a bmp file. Save the width and height in another file have same name but different extension.

To load the image:
1. Allocate some ems mem.
2. Draw the image on a hidden page(eg if view page = 1 then draw page = 0).
3. Get the image in the ems mem using the correct width and height stored in the parallel file.
4. Now if you want transparency or blending use SetMaskColor or SetBlender commands respectively and Future.EMSPut the image on the screen.

 Cool
Logged
TheBigBasicQ
*/-\*
*****
Posts: 4550



WWW
« Reply #6 on: October 11, 2003, 10:37:48 AM »

Ahem....Forgot to mention. Dont forget to unallocate EMS  :lol:
Logged
andy
Senior Member
**
Posts: 175



WWW
« Reply #7 on: October 11, 2003, 12:13:27 PM »

I would use futur.lib, but my laptop whith qb7.1 on is off for repair and I only have the really old version of qb. I have downloaded futur.lib but can#t use it yet.

A gif loader I have loads the images on a white screen, and when i try and view them on on a black screen the image comes out wrong. Is there any way to get around this?
Logged

eminiscing about trapezoids in conjunction with stratospherical parabolas:

No questions asked.

www.stickskate.com
potato
Ancient QBer
****
Posts: 409



WWW
« Reply #8 on: October 11, 2003, 12:20:12 PM »

That's because the gif loader changes the palette. Learn how to use &HC3A (I need ref for this address!) to read the palette, and save the palette in the file with your colors. Then, when you reload the image, use OUT &HC3A, r/g/b to change the palette back.

Rather than go through all of that trouble, you could include the original 256 colors in your gif file. Add a one pixel line with the colors as the first pixel line in the gif file, and the colors will be loaded left to right (generally, depends on your GIF Loader).

Palette manipulation is somewhere in the QBNews FAQ. Someone post a link!
Logged

ammit potato!
TheBigBasicQ
*/-\*
*****
Posts: 4550



WWW
« Reply #9 on: October 11, 2003, 02:44:59 PM »

Quote from: "andy"
I would use futur.lib, but my laptop whith qb7.1 on is off for repair and I only have the really old version of qb. I have downloaded futur.lib but can#t use it yet.

A gif loader I have loads the images on a white screen, and when i try and view them on on a black screen the image comes out wrong. Is there any way to get around this?


In that case I would suggest finding a good bmp loader and saver. Dont go in for a gif loader. You can hardly find a gif saver. BMP savers and loaders are abundant.

But seriously which version of qb do you have? 1.1? 'cause FL will work on 4.5 and 7.1.
Logged
oracle
*/-\*
*****
Posts: 3652



WWW
« Reply #10 on: October 12, 2003, 08:13:32 PM »

http://faq.qbasicnews.com/?blast=GeneralPaletteExplanation
Logged

andy
Senior Member
**
Posts: 175



WWW
« Reply #11 on: October 14, 2003, 11:27:40 AM »

Thank you. My gif loader is called degif (I think), I will check tonight. I will read the faq and hopefully that will shed some light upon the subject.
Logged

eminiscing about trapezoids in conjunction with stratospherical parabolas:

No questions asked.

www.stickskate.com
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!