Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Curious_George

Who Do YOU Rotate A Bitmap In VB

This topic is 6302 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
In DirectX8? Direct3D or DDraw?

If its DirectDraw you cannot rotate in hardware, you will have to create your own blit routine, if you are using D3D you can use D3DXSprite and specify the rotation in ->Draw.

  Game Download  ZeroOne Realm

Share this post


Link to post
Share on other sites
Although it may specify Rotation and alpha blending as a flag in LPDIRECTDRAWSURFACE7->Blt(), it does not work with the majority (if any) of video cards available

As I mentioned before you can implement your own rotation routine if you are good with asm, though the easy solution is to use 3D Hardware to do it for you. I have recently converted my 2D platform game from DDraw7 to D3DX8 with not much difficulty and great results, including as much scaling, rotation, and alpha blending I want

You may download the source for my D3DXWrapper via my site, click below:



  Game Download  ZeroOne Realm

Share this post


Link to post
Share on other sites
D3D is really your only choice. DirectDraw has an option for bitmap rotation in the Blt function, but it is hardware only, and very few video cards support it.

Share this post


Link to post
Share on other sites
Heya,

D3D really your own choice? Why must anything be done by some layer, other software or API?

Can''t we make our own formula''s anymore? Can we just pump polygons into D3D and let D3D do_all_the_rest?

What if Curious_George does not want 3D hardware to be involved?
Maybe his target platform does not have an I_do_everything_for_you layer?

To get some resources about rotating a bitmap, search the internet on rotozoomer''s. A rotozoomer is a demoeffect that rotates a bitmap on screen and well..zooms in and out

Dunno if hornet.org is still up, but that one sure got one...

You should really check out, since programming is more than loading a .x file (with D3DX) and putting it on screen with 1 function call!

Gr,
BoRReL

Share this post


Link to post
Share on other sites
Heya,

No offense, of course!

I know he asked for DirectX!
Still I think switching to D3D for this is ridiculous

Gr,
BoRReL

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
curious george must b a complete idiot to not be able to rotate a bitmap in directx

Share this post


Link to post
Share on other sites
Here''s my rotation from my DX Wrapper for C++

  
RotateBlit(int x, int y, float alpha, SURFACEDATA Scr,
bool ColorKey)
{
DDSURFACEDESC2 SurfaceDesc2;
DDCOLORKEY ddck;
int lPitch2;
USHORT* Buffer2;

int ux,uy,vv;
float hw,hh,x1,y1,x2,y2,x3,y3,mx,my,mx2,my2,ty,ty2,rx,ry,alpha2,r;

alpha = alpha * (2.0f*PI/360.0f);

hw=Scr.Width/2.0f;
hh=Scr.Height/2.0f;


//ColorKey

Scr.Surface->GetColorKey(DDCKEY_SRCBLT, &ddck);

//Locks the destination surface

INITDESC(SurfaceDesc2);
SurfaceData.Surface->Lock(NULL, &SurfaceDesc2, DDLOCK_SURFACEMEMORYPTR |
DDLOCK_WAIT, NULL);
Buffer=(USHORT *)SurfaceDesc2.lpSurface;
lPitch=(int)(SurfaceDesc2.lPitch >> 1);

//Locks the source surface

INITDESC(SurfaceDesc2);
Scr.Surface->Lock(NULL, &SurfaceDesc2, DDLOCK_SURFACEMEMORYPTR |
DDLOCK_WAIT, NULL);
Buffer2=(USHORT *)SurfaceDesc2.lpSurface;
lPitch2=(int)(SurfaceDesc2.lPitch >> 1);

//radien

r=sqrtf(hw*hw+hh*hh);

// #1

/* ux=-hw;
uy=-hh;*/

alpha2=-(acosf(-hw/r))+alpha;
x1=(x+cosf(alpha2)*r);
y1=(y+sinf(alpha2)*r);

// #2

alpha2=-(acosf(-hw/r))+alpha;
x2=(x+cosf(alpha2)*r);
y2=(y+sinf(alpha2)*r);

// #3

alpha2=acosf(hw/r)+alpha;
x3=(x+cosf(alpha2)*r);
y3=(y+sinf(alpha2)*r);

mx=(x2-x1)/(Scr.Width);
my=(y2-y1)/(Scr.Width);
mx2=(x3-x2)/(Scr.Height);
my2=(y3-y2)/(Scr.Height);

for(uy=0;uy<Scr.Height;uy++){
ty=(uy*mx2);
ty2=(uy*my2);
rx=x1;
ry=y1;
for(ux=0;ux<Scr.Width;ux++){
rx+=mx;
ry+=my;

if(Buffer2[ux+uy*lPitch2] != ddck.dwColorSpaceLowValue)
{
vv=int(rx+ty)+int(ry+ty2)*lPitch;
Buffer[vv]=Buffer2[ux+uy*lPitch2];
Buffer[vv+1]=Buffer2[ux+uy*lPitch2];
}
}}


Scr.Surface->Unlock(NULL);
SurfaceData.Surface->Unlock(NULL);
}


/MindWipe

"If it doesn''t fit, force it; if it breaks, it needed replacement anyway."

Share this post


Link to post
Share on other sites
What I do is pre-rotate it during design time, and then just stick all of my rotated images in an array of surfaces or onto one big surface at runtime. This is much faster, and I can control the image quality more. Just another option...

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!