Page 1 of 1

Abducted Pixels

Posted: Sun Jan 23, 2005 11:12 pm
by (Xus)
Someone help me before I go insane; i dimension all my arrays with (width * height)/2 + 2 like I am supposed to, but whenever I BLOAD a tile I dimensioned in the same way, four pixels are missing at the bottom right, all along the bottom border. I'm going crazy with frustration trying to figure out why, and I don't think I'll last much longer. Please help.

Posted: Sun Jan 23, 2005 11:35 pm
by Dr_Davenstein
Can I see your code? That's probably the only way I can help.

Posted: Mon Jan 24, 2005 9:25 pm
by (Xus)
How do I get this thing to display code?[/code]

Posted: Tue Jan 25, 2005 1:27 am
by Dr_Davenstein
The easiest way is to just paste the code in and highlight it. Then just hit the code tag up by the message title. ;)

Posted: Wed Jan 26, 2005 11:57 pm
by (Xus)
I'm using 4.5, so it won't let me copy and paste to this window, and it won't open correctly on Notepad, is what I'm saying. I also tried opening on 1.1 and then opening THAT on Notepad, but to no avail. I've concluded, however, that all the problems lie in my file save/load system. I currently use BSAVE/BLOAD. Would Open...Close work better perhaps? If so, how would I use those commands with an array image?

Posted: Thu Jan 27, 2005 8:26 am
by Dr_Davenstein
To post your code on a message board:

While you are using QBasic, goto FILE, SAVE AS...

You will then see a FORMAT box. In that box, click on TEXT(readable by other programs)... that will save it in ASCII format, instead of BINARY.

Then you can open the file from notepad without getting all the strange binary characters. ;)

QB 1.1 does not open binary files. :cry:

I would highly reccomend to use BLOAD to load images that were saved with BSAVE. They were meant to be used together. There ixs an example program in the QB online help file... You might wanna check it out. ;)

Otherwise, If you want to write your own image loader, check this site out. It has the specs for just about every file format you could ask for. :P

http://www.wotsit.org/


Just look for what you want, take your time, try your best and post some code when you have a problem that you cannot solve. ;)

Posted: Fri Jan 28, 2005 1:46 am
by (Xus)
Holy crap! I had no idea QBasic could save in other formats. Cool. Thanks for all your help. I've now got a slew of things to try before the end of the week, and then I can evaluate them all and opt for the most eficient course of action. Thanks again.

Posted: Fri Jan 28, 2005 9:44 pm
by (Xus)
Question of interest, more than need. Answer only if you'd like to. Could I create a file for my array with open/close rather than bsave, and then save it the same way? If so, would I open as type binary? Then, how would I actually go about reading the array into BASIC? Remember, answer only if you wish. I was just curious.

Posted: Sun Jan 30, 2005 11:25 am
by Dr_Davenstein
Yeah, you could do it that way.

Assuming you have the image drawn in the upper left hand corner, you could do something like this...

Code: Select all

'For SAVING
Open MyFile$ for Output as #1
 For y=0 to imageheight
    For x=0 to imagewidth
       PixelColor$ = STR$(Point(X,Y))
       Print #1, PixelColor$
    Next
 Next
Close #1

Code: Select all

'For LOADING
Open MyFile$ for Input as #1
 For y=0 to imageheight
    For x=0 to imagewidth    
      Input #1, PixelColor$
      PSET(X,Y), VAL(PixelColor$)
    Next
 Next
Close #1

See how it works? ;)

Posted: Sun Jan 30, 2005 9:24 pm
by Ralph
The good Dr_Davenstein may be insane, but he sure knows his programming! My hat is off to you!

Posted: Tue Feb 01, 2005 1:14 am
by (Xus)
Tru. True indeed. I thank all that care.

Posted: Wed Feb 02, 2005 10:36 pm
by ~XUS~
This is a test. Yay! I'm a member!

Posted: Wed Feb 02, 2005 10:38 pm
by ~XUS~
What's this about a "nebie" under my name?!

Posted: Thu Feb 03, 2005 6:58 am
by Dr_Davenstein
Newbie!!! You are a noob!!!!!!!!

Just kidding. :lol:

I think it changes with how long you've been a member, or how many posts you have made... or something. :lol:

Posted: Thu Feb 03, 2005 8:52 pm
by ~XUS~
Hmmm... Ranks in message boards. What an innovative idea.