Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,22 @@ En: [https://github.com/wysaid/android-gpuimage-plus/wiki/Parsing-String-Rule-(E

Ch: [https://github.com/wysaid/android-gpuimage-plus/wiki/Parsing-String-Rule-(ZH)](https://github.com/wysaid/android-gpuimage-plus/wiki/Parsing-String-Rule-(ZH) "http://wysaid.org")

#### Common Filter Examples

**Blur Filters:**
- Mosaic Blur: `@blur mosaic <blurPixels>`
- Example: `@blur mosaic 10.0` (blurPixels >= 1.0, default is 1.0 for origin)

**Style Filters:**
- Polar Pixellate: `@style polarpixellate <pixelSizeX>,<pixelSizeY>` or `@style polarpixellate <centerX>,<centerY>,<pixelSizeX>,<pixelSizeY>`
- Example: `@style polarpixellate 0.05,0.05` (pixel size only, uses default center 0.5,0.5)
- Example: `@style polarpixellate 0.5,0.5,0.05,0.05` (custom center and pixel size)
- Center range: [0, 1], Pixel size range: [0, 0.2]

**Dynamic Filters:**
- Motion Flow: `@dynamic mf <totalFrames>,<frameDelay>`
- Example: `@dynamic mf 10,0` (10 frames with no delay)

## Tool

Some utils are available for creating filters: [https://github.com/wysaid/cge-tools](https://github.com/wysaid/cge-tools "http://wysaid.org")
Expand Down
44 changes: 44 additions & 0 deletions library/src/main/jni/cge/filters/cgeDataParsingEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,33 @@ CGEImageFilterInterface* CGEDataParsingEngine::advancedStyleParser(const char* p
{
ADJUSTHELP_COMMON_FUNC(pstr, CGEPolkaDotFilter, setDotScaling);
}
else if (strcmp(buffer, "polarpixellate") == 0)
{
float centerX, centerY, pixelSizeX, pixelSizeY;
int argNum = sscanf(pstr, "%f%*c%f%*c%f%*c%f", &centerX, &centerY, &pixelSizeX, &pixelSizeY);

if (argNum != 2 && argNum != 4)
{
LOG_ERROR_PARAM(pstr);
return nullptr;
}

auto* filter = createPolarPixellateFilter();

if (filter != nullptr)
{
proc = filter;
if (argNum == 4)
{
filter->setCenter(centerX, centerY);
filter->setPixelSize(pixelSizeX, pixelSizeY);
}
else // argNum == 2, use as pixelSize only
{
filter->setPixelSize(centerX, centerY);
}
}
}
else if (strcmp(buffer, "sketch") == 0)
{
ADJUSTHELP_COMMON_FUNC(pstr, CGESketchFilter, setIntensity);
Expand Down Expand Up @@ -1336,6 +1363,23 @@ CGEImageFilterInterface* CGEDataParsingEngine::blurParser(const char* pstr, CGEM
}
}
}
else if (strcmp(buffer, "mosaic") == 0)
{
float blurPixels;
if (sscanf(pstr, "%f", &blurPixels) != 1)
{
LOG_ERROR_PARAM(pstr);
return nullptr;
}

auto* filter = createMosaicBlurFilter();

if (filter != nullptr)
{
proc = filter;
filter->setBlurPixels(blurPixels);
}
}

else
{
Expand Down