PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Using AlphaBlt and invalid locations

For this application i'm working on, i need to be able to draw the image just slightly off screen, but AlphaBlt seems to just not draw it at all when it gets to the edge.

is there any way of dealing with this?
GapiDraw blits don't showing a surface when it not fully inside the screen (or destination surface), so you should manipulate surfaceRect parameter to avoid getting to the edje. Use the same method for the alphaRect.
I'am using following code for it:

Code:

void SurfaceVO::show(CGapiSurface* dest) {
Rect surfaceRect(x0, y0, x0 + w, y0 + h);
int _x = x;
int _y = y;

int dw = dest->GetWidth();
int dh = dest->GetHeight();

if(x < 0) {
surfaceRect.left -= x;
_x = 0;
}

if(x + w > dw) {
int diff = x + w - dw;
surfaceRect.right -= diff;
}

if(y < 0) {
surfaceRect.top -= y;
_y = 0;
}

if(y + h > dh) {
int diff = y + h - dh;
surfaceRect.bottom -= diff;
}

if (!localAlpha)
r = dest->BltFast(_x, _y, surface, &surfaceRect, bltFastFlags, &blitFX);
else
{
surfaceRect.bottom = y0+h;
Rect alphaRect(surfaceRect.left, surfaceRect.top + h,
surfaceRect.right, surfaceRect.bottom + h);
r = dest->AlphaBltFast(_x, _y, surface, &surfaceRect,
surface, &alphaRect, 0, NULL);
}
}


I'am not sure that my explanation on English is understandable, but this code should answer on your question. :)

Best regards,
AndreyT.
Thanks for this "hack", it worked quite well for my project.

Is there a site or listing of useful hacks like this?