Stuck? Need help? Ask questions on our forums.

Read Post

Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 3376
Number of posts: 11694

This Forum Only
Post New Thread

Edit Report
Getmem/imagesize/putimage = error Posted by Streber on 16 Jun 2000 at 7:44 AM
Hi....i tried to make a program like this.....<br>
<br>
program test;<br>
uses graph,crt;<br>
graphmode,graphdriver : integer;<br>
bild : pointer;<br>
const<br>
maxX = 600;<br>
minX = 40;<br>
maxY = 440;<br>
minY = 40;<br>
begin<br>
<br>
graphmode:=detect;<br>
Initgraph(graphmode,graphdriver,'');<br>
if graphresult<>grok then halt(1);<br>
<br>
setfillstyle(solidfill,8);<br>
bar(0,0,maxX,minY);<br>
bar(0,maxY,maxX,480); <br>
bar(maxX,0,640,480); {drawing a pic}<br>
bar(0,0,minX,maxY);<br>
<br>
getmem(bild,imagesize(0,0,640,480));{get memory}<br>
getimage(0,0,640,480,bild^); {coying the pic}<br>
readln;<br>
<br>
cleardevice; {clears the screen}<br>
readln;<br>
<br>
putimage(1,1,bild^,normalput);<br>
{putting the pic on screen again}<br>
readln;<br>
closegraph;<br>
end.<br>
<br>
<br>
But it doesnt seem to work.....the sh*t crashes when i run it...and some strange red stuff appears<br>
It looks like some kind of chineese alphabet or something.<br>
then i have to reboot<br>
<br>
does anyone know, what im doing wrong....<br>
i will use this to a game im doing (if i can get it to work) <br>
Tank-2000 is the name of the game.<br>
<br>
Cya<br>



Reply
Edit Report
Re: Getmem/imagesize/putimage = error Posted by Jeroen on 19 Jun 2000 at 2:19 AM
<br>
<br>
Hi <br>
<br>
I think your memory buffer is to small<br>
the size of your image is: 640*480=153600 pixels <br>
153600 pixels = 76800 bytes, A memory block can't cross the 64k boundery. If you a allocate the memory you will not allocate 76800 bytes but only 11264 bytes. (76800-65536=11264). Now if you place the picture in this block it will overwrite other information of your program, whitch causes it to hang. <br>
<br>
to solve this problem divide the image in to smaller blocks:<br>
<br>
var pic1,pic2,pic3,pic4:pointer;<br>
<br>
Begin<br>
<br>
getmem(pic1,imagesize(0,0,639,119));<br>
getmem(pic2,imagesize(0,120,639,239));<br>
getmem(pic3,imagesize(0,240,639,359));<br>
getmem(pic4,imagesize(0,360,639,479));<br>
<br>
end<br>
<br>
I hope this will help you and good luck whith tank-2000<br>
<br>
Jeroen<br>



Reply
Edit Report
Re: Re: Getmem/imagesize/putimage = error Posted by Unknown on 19 Jun 2000 at 4:47 AM
Thanks!! Jeroen<br>
<br>
just one more question<br>
<br>
can i do so a Putimage moves smooth over the screen, without ugly redraws <br>
(when i delete the old pic and put it up in another coordinate. )<br>
<br>
example <br>
<br>
Putmimage<br>
cleardevice<br>
putimage new coodinate<br>
cleardevice....<br>
<br>
or can do like this<br>
Drawbackground<br>
Putimage (tank)<br>
Drawbackground<br>
Putimage (tank, new coordinate)<br>
Drawbackground<br>
Putimage (tank, new coordinate)<br>
i think that will be to slow<br>
<br>
<br>
<br>



Reply
Edit Report
Re: Re: Re: Getmem/imagesize/putimage = error Posted by Jeroen on 19 Jun 2000 at 7:44 AM
: Thanks!! Jeroen<br>
: <br>
: just one more question<br>
: <br>
: can i do so a Putimage moves smooth over the screen, without ugly redraws <br>
: (when i delete the old pic and put it up in another coordinate. )<br>
: <br>
: example <br>
: <br>
: Putmimage<br>
: cleardevice<br>
: putimage new coodinate<br>
: cleardevice....<br>
: <br>
: or can do like this<br>
: Drawbackground<br>
: Putimage (tank)<br>
: Drawbackground<br>
: Putimage (tank, new coordinate)<br>
: Drawbackground<br>
: Putimage (tank, new coordinate)<br>
: i think that will be to slow<br>
: <br>
: <br>
: <br>
: <br>
<br>
Hi <br>
perhaps you should try only draw the background at the place where the tank is so:<br>
<br>
getimage (background,...) {place and size of tank}<br>
putimage (tank,...) {place tank}<br>
putimage (background,...)<br>
getimage (background,...) {new coordinates}<br>
putimage (tank,....)<br>
..<br>
..<br>
this is "fast" but you stil got the ugly redraw. <br>
for nice smooth movements you need to draw you entire screen in the back ground en copy it over the old image.<br>
<br>
but for this movement you should know something more aboud the video mode and its memory allocation, so you could write direct to the video memory and not use the bgi driver.<br>
but the mode 640*480*16 is hard to understand, I don't know it. The mode 320*200*256 is a lot easyer, and even faster. there is a tutor over this video mode and how to use it in pascal at <br>
<br>
http://www.strangecreations.com/library/graphics/trainers/index.htm <br>
<br>
tutor 7 is about sprite movement.<br>
<br>
Goodluck Jeroen<br>
<br>



Reply




corner
© 1996-2008. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Publisher: Lars Hagelin.
bootstrapLabs Logo A bootstrapLabs project.