View previous topic :: View next topic |
Author |
Message |
joelcnz
Joined: 23 Feb 2009 Posts: 76
|
Posted: Thu Apr 23, 2009 7:51 pm Post subject: Stretch blit - crash? |
|
|
I think stretch blit
( void stretch_blit(BITMAP *source, BITMAP *dest, int source_x, source_y, source_width, source_height, int dest_x, dest_y, dest_width, dest_height);
)
causes an access violation some times. I mean like I hold a key down and the thing repeatings exact (none of the varibles are changing) same thing over and over, then crashing. |
|
Back to top |
|
|
torhu
Joined: 30 Mar 2006 Posts: 56
|
Posted: Fri Apr 24, 2009 9:21 am Post subject: |
|
|
Most likely there's a bug in your code. It's not possible to help you without seeing more code. |
|
Back to top |
|
|
joelcnz
Joined: 23 Feb 2009 Posts: 76
|
Posted: Sat May 09, 2009 5:41 am Post subject: |
|
|
Some of my programs jumps out, out of the blue and it seems to always be the stretch_blit funtion that I narrow it down too. For example I made my own stretch_blit and that stopped it crashing. |
|
Back to top |
|
|
torhu
Joined: 30 Mar 2006 Posts: 56
|
Posted: Sat May 09, 2009 9:41 am Post subject: |
|
|
Are you sure you're not running out of memory or something? stretch_blit() works fine in the test program that comes with allegro.
99% chance it's something wrong in your code. |
|
Back to top |
|
|
joelcnz
Joined: 23 Feb 2009 Posts: 76
|
Posted: Sat May 09, 2009 10:49 pm Post subject: |
|
|
The function is part of a class (it's a method). It seems to be the thing that tickals the computers thought and makes it spew up. I can't see what the problem is though.
Ok, here's more code:
Code: |
void ReSize( int sw,int sh )
{
writefln("\nIn bmp.d Resize:");
BITMAP* nbmp=create_bitmap( _w=sw,_h=sh );
static char[] nullor(BITMAP* bmp) {
return (bmp is null ? "(null)" : "(some thing)");
}
writefln("next: blit");
blit(_bmp,nbmp,0,0, 0,0, nbmp.w,nbmp.h);
writefln("next: stretch_blit( _bmp=%s,nbmp=%s,0,0,_bmp.w=%d,_bmp.h=%d, 0,0, sw=%d,sh=%d );",
nullor(_bmp),nullor(nbmp),
_bmp.w,_bmp.h, sw, sh);
// stretch_blit( screen,nbmp,0,0,_bmp.w,_bmp.h, 0,0, sw,sh ); // not crash
stretch_blit( _bmp,nbmp,0,0,_bmp.w,_bmp.h, 0,0, sw,sh );
/*
// this not crash
for(int y=0;y<_bmp.h;y++ ) {
for(int x=0;x<_bmp.w;x++ ) {
rectfill(nbmp,x*(sw/_bmp.w),y*(sh/_bmp.h),x*(sw/_bmp.w)+(sw/_bmp.w)-1,y*(sh/_bmp.h)+(sh/_bmp.h)-1,getpixel(_bmp,x,y));
}
}
*/
writefln("next: destroy_bitmap( _bmp );");
destroy_bitmap( _bmp );
_bmp=nbmp;
writefln("done");
} |
|
|
Back to top |
|
|
torhu
Joined: 30 Mar 2006 Posts: 56
|
Posted: Sat May 09, 2009 11:56 pm Post subject: |
|
|
Can't see any obvious problems there. stretch_blit has some restrictions mentioned in the manual, are you sure you're not violating any of them? |
|
Back to top |
|
|
joelcnz
Joined: 23 Feb 2009 Posts: 76
|
Posted: Mon May 18, 2009 11:05 pm Post subject: |
|
|
I can't see how. I'm using a slow way instead at the moment. |
|
Back to top |
|
|
joelcnz
Joined: 23 Feb 2009 Posts: 76
|
Posted: Fri Feb 12, 2010 1:41 am Post subject: |
|
|
It seems only to happen on Windows XP (I've only tried it and Vista though). It seems to work fine on my Vista computer.
I have a work around. I use a function called (helper function, I guess) jstretch_blit where it has the stretch_blit function in a try scope and if an exception is thrown catch uses a slow thing to draw the same thing (one I made my self).
Code: |
void jstretch_blit( BITMAP *source, BITMAP *dest, int source_x, int source_y, int source_width, int source_height,
int dest_x, int dest_y, int dest_width, int dest_height ) {
try {
stretch_blit( source,dest,source_x,source_y,source_width, source_height, dest_x,dest_y, dest_width, dest_height );
}
catch ( Exception e ) {
for(int y=source_y;y<source_height;y++ ) {
for(int x=source_x;x<source_width;x++ ) {
rectfill(dest,
x*(dest_width/source_width), y*(dest_height/source_height),
x*(dest_width/source_width)+(dest_width/source_width)-1, y*(dest_height/source_height)+(dest_height/source_height)-1,
getpixel(source,x,y));
}
}
|
|
|
Back to top |
|
|
torhu
Joined: 30 Mar 2006 Posts: 56
|
Posted: Fri Feb 19, 2010 2:39 pm Post subject: |
|
|
It would be easier to see the problem if you could provide a minimal, compilable program that exhibits the behavior. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|