BMP Graphics Unit

2»

Comments

  • : : : : Say for instance I would want the program to randomly load 1 of 5 pictures. How would I have to change the code? Ive been boggling over this one and simply cant come up with an answer because I dont know how to make the Integer based randomize command agree with something like a file in a directory.
    : : : :
    : : :
    : : : Load your filenames into an array of strings, then use the random number given to index into that array...
    : : :
    : : : -------------
    : : : Ben
    : : : http://journal4cs.blogspot.com/
    : : :
    : : :
    : :
    : : Ive managed to create an array of string to which I assign the names of each file. However, when I try and use that array to call up a file, i get a type mismatch error.
    : :
    : :
    : : Filename[1]:='a';
    : : Filename[2]:='b';
    : : Filename[3]:='c';
    : : Filename[4]:='d';
    : : Filename[5]:='e';
    : : Readln;
    : : Randomize;
    : : i:=Random(5+1);
    : : Writeln(Filename[i]);
    : : Readln;
    : :
    : : i := Round(Random*6+1); { Create a random number from 1 to 5 }
    : :
    : : Graphix($13);
    : : { $13 = 320x200 8-bit (256 Color) Mode }
    : : ClearColor.Index := -1;
    : : { No Clear Color. Set this between 0 & 255 to make a see-through color }
    : : Loaded := ShowBMP(0,0, Filename[i],'.BMP',True,ClearColor,VGA);
    : :
    : :
    : :
    :
    :
    : How is Filename defined? It should be array of string:
    : Var Filename: array[1..20] of string; { is an example }
    : then access via your example:
    :
    : Filename[1]:="a";
    : Filename[2]:="b";
    : Filename[3]:="c";
    : Filename[4]:="d";
    : Filename[5]:="e";
    :
    : Or maybe something longer than a char?
    :
    :
    : -------------
    : Ben
    : http://journal4cs.blogspot.com/
    :
    :


    Ive defined Filename as an Array of String. Still, I cant make it agree with the filename. The compiler wont get past this line:
    Loaded := ShowBMP(0,0, Filename[i],'.BMP' {<------ This is where it stops to say Type Mismatch} ,True,ClearColor,VGA);
  • : Say for instance I would want the program to randomly load 1 of 5 pictures. How would I have to change the code? Ive been boggling over this one and simply cant come up with an answer because I dont know how to make the Integer based randomize command agree with something like a file in a directory.
    :

    Ive managed to Randomly call up 1 of 5 pictures. Now my problem is that when the program displayes any of these 5, it does so in the wrong resolution, ie. the monitor only shows a fraction of the actual image.
    Ive tried saving the bmp file in different color modes, but that didnt help. Any ideas?


  • [b][red]This message was edited by Phat Nat at 2005-8-27 16:57:21[/red][/b][hr]
    : : : : : Say for instance I would want the program to randomly load 1 of 5 pictures. How would I have to change the code? Ive been boggling over this one and simply cant come up with an answer because I dont know how to make the Integer based randomize command agree with something like a file in a directory.
    : : : : :
    : : : :
    : : : : Load your filenames into an array of strings, then use the random number given to index into that array...
    : : : :
    : : : : -------------
    : : : : Ben
    : : : : http://journal4cs.blogspot.com/
    : : : :
    : : : :
    : : :
    : : : Ive managed to create an array of string to which I assign the names of each file. However, when I try and use that array to call up a file, i get a type mismatch error.
    : : :
    : : :
    : : : Filename[1]:='a';
    : : : Filename[2]:='b';
    : : : Filename[3]:='c';
    : : : Filename[4]:='d';
    : : : Filename[5]:='e';
    : : : Readln;
    : : : Randomize;
    : : : i:=Random(5+1);
    : : : Writeln(Filename[i]);
    : : : Readln;
    : : :
    : : : i := Round(Random*6+1); { Create a random number from 1 to 5 }
    : : :
    : : : Graphix($13);
    : : : { $13 = 320x200 8-bit (256 Color) Mode }
    : : : ClearColor.Index := -1;
    : : : { No Clear Color. Set this between 0 & 255 to make a see-through color }
    : : : Loaded := ShowBMP(0,0, Filename[i],'.BMP',True,ClearColor,VGA);
    : : :
    : : :
    : : :
    : :
    : :
    : : How is Filename defined? It should be array of string:
    : : Var Filename: array[1..20] of string; { is an example }
    : : then access via your example:
    : :
    : : Filename[1]:="a";
    : : Filename[2]:="b";
    : : Filename[3]:="c";
    : : Filename[4]:="d";
    : : Filename[5]:="e";
    : :
    : : Or maybe something longer than a char?
    : :
    : :
    : : -------------
    : : Ben
    : : http://journal4cs.blogspot.com/
    : :
    : :
    :
    :
    : Ive defined Filename as an Array of String. Still, I cant make it agree with the filename. The compiler wont get past this line:
    : Loaded := ShowBMP(0,0, Filename[i],'.BMP' {<------ This is where it stops to say Type Mismatch} ,True,ClearColor,VGA);
    :

    Your problem is that you are trying to pass another parameter to the function. Notice the subtle difference between the first and second that talls the compiler that it is still the same variable that you are passing:

    [code]
    Loaded := ShowBMP(0,0, Filename[i] , '.BMP',True,ClearColor,VGA); {Wrong}
    Loaded := ShowBMP(0,0, Filename[i] + '.BMP',True,ClearColor,VGA); {Right}
    [/code]

    Phat Nat



  • : : : : : Say for instance I would want the program to randomly load 1 of 5 pictures. How would I have to change the code? Ive been boggling over this one and simply cant come up with an answer because I dont know how to make the Integer based randomize command agree with something like a file in a directory.
    : : : : :
    : : : :
    : : : : Load your filenames into an array of strings, then use the random number given to index into that array...
    : : : :
    : : : : -------------
    : : : : Ben
    : : : : http://journal4cs.blogspot.com/
    : : : :
    : : : :
    : : : how i use turbo pascal for window, how can i operate this program.
    : : : Also, where can i download "Borland Turbo Pascal 7"?
    : : :
    : : You can get Turbo Pascal at www.borland.com.
    : :
    : if i use borland turbo pascal 5.5, how can i run the program
    :

    I might be able to translate it to a 5.5 compatible format for you ( I May even have one). TP5.5 doesn't support the Built in Assembler (BASM) that TP7 does. So all of the assembly code needs to be changed to Inline(); Statements. This can be done with DEBUG, but is somewhat time consuming. I'll see if I have one somewhere.

    Phat Nat

  • [b][red]This message was edited by Phat Nat at 2005-8-27 18:34:8[/red][/b][hr]
    : : Say for instance I would want the program to randomly load 1 of 5 pictures. How would I have to change the code? Ive been boggling over this one and simply cant come up with an answer because I dont know how to make the Integer based randomize command agree with something like a file in a directory.
    : :
    :
    : Ive managed to Randomly call up 1 of 5 pictures. Now my problem is that when the program displayes any of these 5, it does so in the wrong resolution, ie. the monitor only shows a fraction of the actual image.
    : Ive tried saving the bmp file in different color modes, but that didnt help. Any ideas?
    :

    You either need to resize the BMPs in Paint, etc or use a different video mode (other than $13)
    [code]
    Graphix($13); { $13 = 320x200 8-bit (256 Color) Mode }
    [/code]
    [code]
    Graphix($101); { $101 = 640x480 8-bit (256 Color) Mode }
    [/code]

    I can't gaurentee how well it works with Higher resolution modes. I made it a long time ago and haven't used it on higher modes much since. Try it out though and see.

    Phat Nat

    Just tried it and managed to load a 640x480 24-bit BMP with no problems using Graphix($111);


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories