Dynamische Arrays
Hallo,
da ich das Avisynth-Plugin nicht in Delphi zum Laufen bekomme, wollte ich rkFastBlur von Roy Magne Klever aus dem Beitrag in Visual Studio Express 2012 C++ nachbauen. Ich habe bisher nur das waagerechte Verwischen versucht. Als Ergebnis erhalte ich jedoch kein Rechteck sondern nur einen senkrechen Strich, welcher den rechten Rand des Rechteckes darstellt. Ich nehme an, dass es an der Deklaration der dynamischen Arrays liegt. Ich habe einiges im Internet gefunden, aber nichts hat bisher funktioniert.
Code:
Zum Beispiel funktioniert nicht:
const unsigned int Entries = maskWidth + 1 + 2 * radius;
int* blurB = new int[Entries]; int* blurG = new int[Entries]; int* blurR = new int[Entries]; int tmp; minH = vi.height - maskTop - maskHeight; maxH = vi.height - maskTop - 1; minW = maskLeft * 3; maxW = (maskLeft + maskWidth - 1) * 3; dstp = dst->GetWritePtr(); dstp = dstp + (minH * dst_pitch); for (h = minH; h < maxH; h ++) { for (rp = 0; rp < replays; rp ++) { for (w = (minW - radius * 3); w < (maxW + radius * 3); w += 3) { tmp = w; if (w < minW) { tmp = minW; } else { if (tmp > maxW) { tmp = maxW; } } if (minW = (w - radius * 3)) { blurB[0] = *(dstp + tmp); blurG[0] = *(dstp + tmp + 1); blurR[0] = *(dstp + tmp + 2); } else { blurB[w / 3] = blurB[(w / 3) - 1] + *(dstp + tmp); blurG[w / 3] = blurG[(w / 3) - 1] + *(dstp + tmp + 1); blurR[w / 3] = blurR[(w / 3) - 1] + *(dstp + tmp + 2); } } for (w = 0; w < (maxW - minW); w += 3) { *(dstp + minW + w) = (blurR[w + radius + 1] - blurR[w + radius]) / (radius * 2 + 1); *(dstp + minW + w + 1) = (blurG[w + radius + 1] - blurG[w + radius]) / (radius * 2 + 1); *(dstp + minW + w + 2) = (blurB[w + radius + 1] - blurB[w + radius]) / (radius * 2 + 1); } } dstp = dstp + dst_pitch; }
Code:
int** blurB;
blurB = (int**)calloc(Entries, sizeof(int*)); int** blurG; blurG = (int**)calloc(Entries, sizeof(int*)); int** blurR; blurR = (int**)calloc(Entries, sizeof(int*));
Code:
const unsigned int N = 4;
int c[N]; |
AW: Dynamische Arrays
Die letzte Schleife habe ich nun geändert nach:
Code:
Die / 3 hatte ich vergessen. Durch die Bereichsänderung ist es aber kein senkrechter Strich mehr sondern das Zielrechteck steht rechts neben dem Quellrechteck.
for (w = 0; w < maskWidth * 3; w += 3)
{ *(dstp + minW + w) = (blurR[w / 3 + radius + 1] - blurR[w / 3 + radius]) / (radius * 2 + 1); *(dstp + minW + w + 1) = (blurG[w / 3 + radius + 1] - blurG[w / 3 + radius]) / (radius * 2 + 1); *(dstp + minW + w + 2) = (blurB[w / 3 + radius + 1] - blurB[w / 3 + radius]) / (radius * 2 + 1); } Es scheint an den Pointern in diesem Bereich zu liegen:
Code:
Es soll der Farbwert von *(dstp + tmp) nach blurB[0] usw übertragen werden. Wenn ich den Bereich auskommentiere, liegen die Rechtecke übereinander.
if (minW = (w - radius * 3))
{ blurB[0] = *(dstp + tmp); blurG[0] = *(dstp + tmp + 1); blurR[0] = *(dstp + tmp + 2); } else { blurB[w / 3] = blurB[(w / 3) - 1] + *(dstp + tmp); blurG[w / 3] = blurG[(w / 3) - 1] + *(dstp + tmp + 1); blurR[w / 3] = blurR[(w / 3) - 1] + *(dstp + tmp + 2); } Gauss funktioniert:
Code:
Allerdings sind hier blurR, blurG und blurB vom Typ Int. Oben wegen den Array int*. Ein
const unsigned int matrix[25] = {1, 4, 7, 4, 1, 4, 16, 26, 16, 1, 7, 26, 41, 26, 7, 4, 16, 26, 16, 4, 1, 4, 7, 4, 1};
int w, h, mw, mh, rp; int minW, maxW, minH, maxH; unsigned int blurR, blurG, blurB; unsigned int idx; unsigned int count; minH = vi.height - maskTop - maskHeight; maxH = vi.height - maskTop - 1; minW = maskLeft * 3; maxW = (maskLeft + maskWidth - 1) * 3; for (rp = 0; rp < replays; rp ++) { dstp = dst->GetWritePtr(); dstp = dstp + (minH * dst_pitch); for (h = minH; h < maxH; h ++) { for (w = minW; w < maxW; w += 3) { blurR = 0; blurG = 0; blurB = 0; count = 0; for (mh = -2; mh < +2; mh ++) { for (mw = -6; mw < +6; mw += 3) { if ((0 <= h + mh) && (h + mh < dst_height) && (0 <= w + mw) && (w + mw < dst_width)) { idx = (mh + 2) * 5 + abs((int)((mw + 6) / 3)); count = count + matrix[idx]; blurR = blurR + (*(dstp + w + (mw * dst_pitch)) * matrix[idx]); blurG = blurG + (*(dstp + w + (mw * dst_pitch) + 1) * matrix[idx]); blurB = blurB + (*(dstp + w + (mw * dst_pitch) + 2) * matrix[idx]); } } } if (count > 0) { *(dstp + w) = blurR / count; // Blauwert eintragen. *(dstp + w + 1) = blurG / count; // Grünwert eintragen. *(dstp + w + 2) = blurB / count; // Rotwert eintragen. } } dstp = dstp + dst_pitch; } }
Code:
bringt leider auch nichts.
blurB[0] = (int)*(dstp + tmp);
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:36 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz