JEPEG Viewer

Ein mehr praktisches Tutorial von Jochen Reichenberg
Hier ist ein Demo Projekt im C++Builder 6 Format, welches Demostriert, wie man

Insbesondere die Routine zu drehen kann als Beispiel für den Umgang mit Bitmap-Daten dienen:

void __fastcall TFormJPEGViewer::RotateBitmap(void)
{

	int ymaxrot;
	int xmaxrot;

	if (bmp_rotate == 2 || bmp_rotate == 0)
	{
		ymaxrot = ymaxorg;
		xmaxrot = xmaxorg;
	}
	else
	{
		ymaxrot = xmaxorg;
		xmaxrot = ymaxorg;
	}

	BitmapShow->Width = xmaxrot;
	BitmapShow->Height = ymaxrot;

	Byte* slRotated;
	pImagedata = Imagedata;

	if (bmp_rotate == 0) // 0° gedreht
	{
		for (int y = ymaxrot - 1; y >= 0; y--)
		{
			slRotated = (Byte*) BitmapShow->ScanLine[y];
			for (int x = xmaxrot - 1; x >= 0; x--)
			{
				*slRotated = *pImagedata;
				slRotated++;
				pImagedata++;
			}
		}
	}

	if (bmp_rotate == 2) // 180° gedreht
	{

		for (int y = 0; y < ymaxrot; y++)
		{
			slRotated = (Byte*) BitmapShow->ScanLine[y];
			slRotated += xmaxrot - 1;
			for (int x = 0; x < xmaxrot; x++)
			{
				*slRotated = *pImagedata;
				slRotated--;
				pImagedata++;
			}
		}
	}

if (bmp_rotate == 3) // 270° gedreht
 {
  for (int y = ymaxrot - 1; y >= 0; y--)
  {
   slRotated = (Byte*) BitmapShow->ScanLine[y];
   slRotated += xmaxrot - 1;
   for (int x = 0; x < xmaxrot; x++)
   {
    *slRotated = Imagedata[ymaxrot - 1 - y + (x * xmaxorg)];
    slRotated--;
   }
  }
 }

 if (bmp_rotate == 1) // 90° gedreht
 {
  for (int y = 0; y < ymaxrot; y++)
  {
   slRotated = (Byte*) BitmapShow->ScanLine[y];
   for (int x = 0; x < xmaxrot; x++)
   {
    *slRotated = Imagedata[y + (x * xmaxorg)];
    slRotated++;
   }
  }
 }
	bmp_rotate_old = bmp_rotate;
}

Download Demo-Projekt JPEG-Viewer