   Bitmap Softrware Rotation
  Greetings. I am attempting to write software rotation for surfaces in Direct Draw but it does not seem to work. The surface is being drawn but the rotation fails. I am rotating the image pixel by pixel. Here is the code:// Rotate and draw a surface at a given location (note that the image rotates at the // center of the surface and cannot rotate from any other pointint DD_OBJ::DrawRotatedAt(int x, int y, int width, int height, LPDIRECTDRAWSURFACE7 surface, int angle){  HDC hdc;  DDSURFACEDESC2 ddsd;    surface->GetDC(&hdc); // acquire the dc of the surface    RECT rect = {x, y, x + width, y + height};  RECT src = {0, 0, width, height};    double cx = (double)(width / 2); // Calculate the center of the map  double cy = (double)(height / 2);    surface->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR, NULL); // lock surfacefor(int wi = 0; wi < width; wi++) // wi = width iterator  {    for(int hi; hi < height; hi++) // hi = height iterator    { double x1 = (double)wi - cx; // find the distance from the center double y1 = (double)hi - cy;  double tx = ((x1 * COSINE[angle]) - (x1 * SINE[angle])); // Rotate the vertex double ty = ((y1 * SINE[angle]) + (y1 * COSINE[angle]));  int rx = (int)(tx + cx); // find the new pixel in relation to the center int ry = (int)(ty + cy);  if(rx <= width && ry <= height && rx >= 0 && ry >= 0) {   COLORREF colorofpixel = GetPixel(hdc, wi, hi); // get the color of the pixel   SetPixel(hdc, rx, ry, colorofpixel); // set the rotated pixel color }    }  }    surface->Unlock(NULL); // unlock the surface    surface->ReleaseDC(hdc); // release the device context    if(BlitToBackSurface(rect, surface, src, TRUE) != BLT_OK) // blit the surface to the back surface    {TankLog->Log("Failed to blit rotated image...\n");}  }Any help would be appreciated. - Jeff Foster, Premonition Stuidos   Visit the Premonition Studios Web Site----------------------------------------------- 
  Check your API return values.  You''ll find that Lock is failing because you already have obtained an internal lock on the surface when calling GetDC. ;  Well that is one of the problems but the surface still isnt rotating. It just remains static in its origional orientaion.... I could use some more help!  Visit the Premonition Studios Web Site----------------------------------------------- ;  I''ve never seen an HDC and a Locked surface used together like this, so I''m unsure of the results.  I''d recommend simple editing the pixel data manually using the surface pointer that you requested in Lock.  You should probably have a wrapper to plot pixels etc.One more thing: you will get a very bad result if you run this algorithm for each pixel in the SOURCE image, and map it to a TARGET pixel... you''ll get lots of holes etc.  It really has to be run the other way around.Lastly, remember that your rotated image will probably require a LARGER canvas than the original.  Furthermore, make sure that your rotated image is drawing to a different surface than your source (you''ll need a temporary surface at the very least).I don''t have time to go into detail (gotta get to class , but I hope that points you in the right direction. 