-
-
Notifications
You must be signed in to change notification settings - Fork 34
png render problem #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Given the code you provided, I have no problem with that image. The first rendered image you provide seems to be clipped. Can you provide the code which clip the drawing? Here is an example of an image painted in a circle with a stroked border:
|
with the following code, I can reproduce the same result:
I'll make further analysis and come back to you with more info... |
|
all code here from the file: vkvg/tests/img_surf.c, the problem still exists. `#include "test.h" const char* imgPath = "E:/vkvg/tests/data/miroir.png"; void paint () {
}
}
}
}
} static float angle = 0;
}
} void paint_pattern () { void test(){
} int main(int argc, char *argv[]) {
} |
Trying with compilation option -DVKVG_PREMULT_ALPHA=false (disabling alpha pre-multiplication, the white border disappears. It would surely be a good improvement to provide alpha premult handling for image loading api. The quick solution for now is to load an image with pre multiplied alpha encoding. |
Usually, when image has alpha-premultiplied pixels, there is a loss of information. So when writing images to disk, it is better to have it without alpha premultiplication. |
@ #156 task created. |
I want to draw multiple pictures. I've enabled the VK_BLEND_FACTOR_SRC_ALPHA & VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA. These pictures together form an image. Later, I want to draw some text or circles at certain positions on this image. However, after I finish drawing the text, the image part disappears. How can I achieve the desired effect using your functions?
} //-------------------------------------- void paint () {
} |
Below is my OpenGL code. I want to migrate the functionality of this code to Vulkan. #include class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions
protected:
private:
}; #endif // ` |
I'm deeply focused on another project of mine, sorry but I will take some time to reply, I will try to give you the big picture before Tuesday. |
After making some tests, there is maybe an unexpected behavior when painting an image without a path like the following code:
With this code, the paint is done with a full screen quad, replacing alpha channel of the whole target surface even where the image is not drawn. This behavior is not what could be intuitively expected. If something is already painted, the colors channels are preserve but the alpha is set to 0. A simple workaround for now is to paint image with explicit path like the following code:
You may also clip the drawing to avoid painting outside desired region, in this scenario the results are equivalent:
With the first example, the whole target surface is affected, but only the alpha channel. That's why on screen the picture looks as expected (the swapchain's images have no alpha channel). I've created an issue: #157 but I'm not completely sure this should be considered as a bug. Paint(ctx) calls do full surface painting, if VKVG_EXTEND_* are used, affecting the whole target is the expected behavior. Default image extend is VKVG_EXTEND_NONE, if preventing affecting the whole alpha channel imply small or easy change, this could be changed. If not, the current behavior should be explained in documentation. Thank you for your reporting. ` |
code:
const char* imgPath = "E:/vkvg/tests/data/miroir.png";
const char* imgPath2 = "E:/vkvg/tests/data/filled.png";
void paint () {
VkvgContext ctx = vkvg_create(surf);
vkvg_set_line_width(ctx, 1.0); // 设置线宽
vkvg_set_line_cap(ctx, VKVG_LINE_CAP_ROUND); // 设置线条端点样式
vkvg_set_line_join(ctx, VKVG_LINE_JOIN_ROUND); // 设置线条连接样式
}
//----------
sample project: img_surf
configure code:
//-------------------------------
static bool paused = false;
static bool offscreen = false;
static bool threadAware = false;
static VkSampleCountFlags samples = VK_SAMPLE_COUNT_64_BIT;
static VkPhysicalDeviceType preferedPhysicalDeviceType = VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;
static vk_engine_t* e;
static char* saveToPng = NULL;
The text was updated successfully, but these errors were encountered: