Hallo Leute,
irgendwie bin ich zu doof dazu...
Ich muß hier einen kleinen JPEGViewer in ein Programm integrieren. Eigentlich kein Problem, aber das Bitmap muß um 90° drehbar sein.
Die JPEGs liegen alle in Graustufen vor. Jedoch gelingt es mir nicht, eine von dem JPEG abgeleitete Bitmap bei Pixelformat = pf8Bit auch nur in ein anderes Bitmap zu schreiben.
Mit pf24Bit ist mir das durchaus gelungen. Allerdings ist die Routine VIEL zu langsam (4 Sek. auf einem P266, die JPEGs sind alle DINA4).
Also habe ich mir gedacht, ich schreibe die Daten in Array, und baue aus diesem Array ein neues Bitmap auf... Funktioniert allerdings nicht. Man kann das Bitmap soeben noch erraten, allerdings mit sehr vielen Fehlfarben.
Hier die Testroutine, mit der ich versuche die Daten von einem in ein anderes Bitmap zu schreiben. Beim Erzeuben des gedrehten Bitmaps wird die Farbpalette und das Pixelformat aus dem Originalbitmap übernommen, ebenso wie die Größe.
<PRE>
int ymax = BitmapOriginal->Height;
int xmax = BitmapOriginal->Width;
Byte* slRotated;
Byte* slOriginal;
Byte* Imagedata = new Byte[xmax * ymax];
Byte* pImagedata;
pImagedata = Imagedata;
for (int y = ymax - 1; y >= 0; y--)
{
slOriginal = (Byte*) BitmapOriginal->ScanLine[y];
for (int x = xmax - 1; x >= 0; x--)
{
*pImagedata = *slOriginal;
slOriginal++;
pImagedata++;
}
}
pImagedata = Imagedata;
for (int y = ymax - 1; y >= 0; y--)
{
slRotated = (Byte*) BitmapRotated->ScanLine[y];
for (int x = xmax - 1; x >= 0; x--)
{
*slRotated = *pImagedata;
slRotated++;
pImagedata++;
}
}
delete Imagedata;
</PRE>
Falls ich, nach Durchlauf der Routine, die Palette erneut auf die Originalpalette setze, wird das gesamte Bitmap schwarz ausgegeben.
Was übersehe ich dabei? Jemand eine Idee?
Wen es interessiert, hier ist die Methode, die bei pf24Bit funktioniert, aber eben zu langsam ist:
<PRE>
RGBTRIPLE* slRotated;
RGBTRIPLE* slOriginal;
for (int y = 0; y < BitmapRotated->Height; y++)
{
slRotated = (RGBTRIPLE*) BitmapRotated->ScanLine[y];
for (int x = 0; x < BitmapRotated->Width; x++)
{
slOriginal = (RGBTRIPLE*) BitmapOriginal->ScanLine[x];
slRotated[x] = slOriginal[BitmapOriginal->Width - y - 1];
}
}
</PRE>
Vielen Dank schon mal,
Jochen
irgendwie bin ich zu doof dazu...
Ich muß hier einen kleinen JPEGViewer in ein Programm integrieren. Eigentlich kein Problem, aber das Bitmap muß um 90° drehbar sein.
Die JPEGs liegen alle in Graustufen vor. Jedoch gelingt es mir nicht, eine von dem JPEG abgeleitete Bitmap bei Pixelformat = pf8Bit auch nur in ein anderes Bitmap zu schreiben.
Mit pf24Bit ist mir das durchaus gelungen. Allerdings ist die Routine VIEL zu langsam (4 Sek. auf einem P266, die JPEGs sind alle DINA4).
Also habe ich mir gedacht, ich schreibe die Daten in Array, und baue aus diesem Array ein neues Bitmap auf... Funktioniert allerdings nicht. Man kann das Bitmap soeben noch erraten, allerdings mit sehr vielen Fehlfarben.
Hier die Testroutine, mit der ich versuche die Daten von einem in ein anderes Bitmap zu schreiben. Beim Erzeuben des gedrehten Bitmaps wird die Farbpalette und das Pixelformat aus dem Originalbitmap übernommen, ebenso wie die Größe.
<PRE>
int ymax = BitmapOriginal->Height;
int xmax = BitmapOriginal->Width;
Byte* slRotated;
Byte* slOriginal;
Byte* Imagedata = new Byte[xmax * ymax];
Byte* pImagedata;
pImagedata = Imagedata;
for (int y = ymax - 1; y >= 0; y--)
{
slOriginal = (Byte*) BitmapOriginal->ScanLine[y];
for (int x = xmax - 1; x >= 0; x--)
{
*pImagedata = *slOriginal;
slOriginal++;
pImagedata++;
}
}
pImagedata = Imagedata;
for (int y = ymax - 1; y >= 0; y--)
{
slRotated = (Byte*) BitmapRotated->ScanLine[y];
for (int x = xmax - 1; x >= 0; x--)
{
*slRotated = *pImagedata;
slRotated++;
pImagedata++;
}
}
delete Imagedata;
</PRE>
Falls ich, nach Durchlauf der Routine, die Palette erneut auf die Originalpalette setze, wird das gesamte Bitmap schwarz ausgegeben.
Was übersehe ich dabei? Jemand eine Idee?
Wen es interessiert, hier ist die Methode, die bei pf24Bit funktioniert, aber eben zu langsam ist:
<PRE>
RGBTRIPLE* slRotated;
RGBTRIPLE* slOriginal;
for (int y = 0; y < BitmapRotated->Height; y++)
{
slRotated = (RGBTRIPLE*) BitmapRotated->ScanLine[y];
for (int x = 0; x < BitmapRotated->Width; x++)
{
slOriginal = (RGBTRIPLE*) BitmapOriginal->ScanLine[x];
slRotated[x] = slOriginal[BitmapOriginal->Width - y - 1];
}
}
</PRE>
Vielen Dank schon mal,
Jochen
Comment