Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pictures in an exe?
#21
Well the custom file format is a cross-compatible format that can be loaded in any screen mode which supports &h###### as color. And with the DATA statements, I tried using them and failed, I can't get them to work. Can anyone help me with the DATA part?
Reply
#22
Code:
Screen 13

FOR Y = 1 to 20
FOR X = 1 to 20
read z
pset (x,y),z
next
next

DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20

I also remember someone awhile ago posting the code to get the rgb co-ordinates of a pixel. Using that should avoid the whole screen incompatibility thing.
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply
#23
I made a program a few years ago that dumped the screen as a series of DRAW statements that would re-draw the image. You could load a BMP first, use this program to convert that image to DRAW data, then put those DRAW statememnts in your code so you don't have to distribute another file with your EXE.

It was for Qbasic , don't know if it will work with FB yet, but you can have it if you want.

- Dav
Reply
#24
I'm sure I can try and get it to work for fb, and if I do, i'll send back. Also, I've used other people's DATA statements before, but making own is the hard part.
Reply
#25
Cool. Here it is then - but it's NOT FreeBasic compatible yet. I just tried it. In Qbasic, PSET will place the graphics drawing cursor to that location, doesn't look like FB's PSET does that yet. Maybe I'll just add cords in the DRAW statements instead of PSETing them (ex: M1,120). Also, not 100% sure, but I don't think the pallette OUT statements are compatible with FB's so I'd leave'em out until sure.

This code will create a DRAW.BAS file in the current directory. Try it in Qbasic to see it working.

Btw, you can download this program and more in the QB code book: codebook.exe (800k)

- Dav

Code:
' ============
' DRAWCAP2.BAS
' ============
' Coded by Dav for THE CODE POST
' http://www.thecodepost.com

' ** PALLETTE data is now saved **

' This utility SUB captures an area of the screen as a BAS file
' containing DRAW statements that, when run, will recreate the area
' exactly as before. Pallette data is also saved.

' This program is useful if you have a small image you want to be
' included in the program. Just load your image and call DRAWCAP with
' the area to save and file to save as, then add the resulting file
' of BAS code to your program.

' The saved BAS code is often very large - usually too large to have
' in your main code. So, I recommend load the resulting BAS as a module
' instead. This way you can use many such BAS images in your programs.

' =========================================================
' NOTE: This demo creates a file called DRAW.BAS in current
' directory if ran without alteration.
' =========================================================

DEFINT A-Z
DECLARE SUB DRAWCAP (x1%, y1%, x2%, y2%, file$)

SCREEN 13

'=== DEMO BEGINS

'=== Let's create something to save...

FOR d% = 1 TO 100
    LOCATE RND * 24 + 1, RND * 39 + 1
    COLOR RND * 255
    PRINT "*";
NEXT

'=== Now we'll capture the WHOLE screen to file.
'=== You don't have to save the whole screen...
'=== just specify below what you want to saved.

DRAWCAP 0, 0, 319, 199, "DRAW.BAS"

'=== DEMO ENDS

END

SUB DRAWCAP (x1%, y1%, x2%, y2%, file$)

'=== This is a new DRAWCAP routine - Version 2
'=== It saves the given area of screen to a BAS code containing
'=== DRAW statements that recreates the same screen when it's run.
'=== The Pallette data is also captured and save to the BAS code.

'=== Open output file

    OPEN file$ FOR OUTPUT AS 1
  
    PRINT #1, "SCREEN 13"

'=== Grab and save current pallette

    PRINT #1, "A$="; CHR$(34); CHR$(34); ":";
    PRINT #1, "A$="; CHR$(34);

    OUT 967, 0: b% = 0
    FOR c% = 1 TO 768
      Pal$ = CHR$(INP(969)): b% = b% + 1
      PRINT #1, RIGHT$("0" + HEX$(ASC(Pal$)), 2);
      IF b% = 30 THEN
        PRINT #1, : PRINT #1, "A$ = A$+"; CHR$(34);
        b% = 0
      END IF
    NEXT: PRINT #1,

'=== Write routine that loads saved pallette
  
    PRINT #1, "c% = 0"
    PRINT #1, "FOR i%=1 TO LEN(A$) STEP 6"
    PRINT #1, " OUT 968, c%:c% = c% +1"
    PRINT #1, " OUT 969, VAL("; CHR$(34); "&H"; CHR$(34); "+MID$(A$,i%,2))"
    PRINT #1, " OUT 969, VAL("; CHR$(34); "&H"; CHR$(34); "+MID$(A$,i%+2,2))"
    PRINT #1, " OUT 969, VAL("; CHR$(34); "&H"; CHR$(34); "+MID$(A$,i%+4,2))"
    PRINT #1, "NEXT:A$="; CHR$(34); CHR$(34)

'=== Capture the given area as DRAW statements.

FOR y% = y1% TO y2%
      SL% = 1
      PRINT #1, "PSET("; LTRIM$(RTRIM$(STR$(x1%))); ",";
      PRINT #1, LTRIM$(RTRIM$(STR$(y%))); "):";
      PRINT #1, "DRAW"; CHR$(34);
      FOR x% = x1% TO x2%
         Clr% = POINT(x%, y%)
         IF Clr% = POINT(x% + 1, y%) THEN
            c% = 2: x% = x% + 2
            DO WHILE POINT(x%, y%) = Clr%
               c% = c% + 1: x% = x% + 1
               IF x% = x2% THEN EXIT DO
               IF c% = y2% THEN EXIT DO
            LOOP
            PRINT #1, "C"; LTRIM$(RTRIM$(STR$(Clr%))); "R"; LTRIM$(RTRIM$(STR$(c%)));
            x% = x% - 1
         ELSE
            PRINT #1, "C"; LTRIM$(RTRIM$(STR$(Clr%))); "R1";
         END IF
         SL% = SL% + 1
         IF SL% = 15 AND x% < x2% THEN
            PRINT #1, CHR$(32)
            PRINT #1, "DRAW"; CHR$(34);
            SL% = 1
         END IF
      NEXT
      PRINT #1, CHR$(34)
      '=== erase what was saved (for show)
      LINE (x1%, y%)-(x2%, y%), 0
NEXT

CLOSE 1

END SUB
Reply
#26
Well I lost my copy of QB, so I tried it in fb, but when I open the DRAW.BAS file in fb and compile, the image is enlarged by wuite a but. That kind of sucks, but good job.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)