Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Source/NVGSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void NVGSurface::updateBufferSize()
if (fbWidth != scaledWidth || fbHeight != scaledHeight || !invalidFBO) {
if (invalidFBO)
nvgDeleteFramebuffer(invalidFBO);
invalidFBO = nvgCreateFramebuffer(nvg, scaledWidth, scaledHeight, NVG_IMAGE_PREMULTIPLIED);
invalidFBO = nvgCreateFramebuffer(nvg, scaledWidth, scaledHeight, 0);
fbWidth = scaledWidth;
fbHeight = scaledHeight;
invalidArea = getLocalBounds();
Expand Down
22 changes: 3 additions & 19 deletions Source/Utility/NVGGraphicsContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void NVGGraphicsContext::clipToImageAlpha(juce::Image const& sourceImage, juce::
// Create a new Nanovg image from the bitmap data
int const width = singleChannelImage.getWidth();
int const height = singleChannelImage.getHeight();
auto const image = nvgCreateImageRGBA(nvg, width, height, 0, pixelData);
auto const image = nvgCreateImageARGB_sRGB(nvg, width, height, 0, pixelData);
auto const paint = nvgImagePattern(nvg, 0, 0, width, height, 0, image, 1);

nvgSave(nvg);
Expand Down Expand Up @@ -566,24 +566,8 @@ int NVGGraphicsContext::getNvgImageId(juce::Image const& image)

argbImage = argbImage.convertedToFormat(juce::Image::PixelFormat::ARGB);
juce::Image::BitmapData const bitmap(argbImage, juce::Image::BitmapData::readOnly);

for (int y = 0; y < argbImage.getHeight(); ++y) {
auto* scanLine = reinterpret_cast<juce::uint32*>(bitmap.getLinePointer(y));

for (int x = 0; x < argbImage.getWidth(); ++x) {
juce::uint32 const argb = scanLine[x];

juce::uint8 const a = argb >> 24;
juce::uint8 const r = argb >> 16;
juce::uint8 const g = argb >> 8;
juce::uint8 const b = argb;

// order bytes as abgr
scanLine[x] = a << 24 | b << 16 | g << 8 | r;
}
}

id = nvgCreateImageRGBA(nvg, argbImage.getWidth(), argbImage.getHeight(), NVG_IMAGE_PREMULTIPLIED, bitmap.data);

id = nvgCreateImageARGB(nvg, argbImage.getWidth(), argbImage.getHeight(), 0, bitmap.data);

if (images.size() >= maxImageCacheSize)
reduceImageCache();
Expand Down
6 changes: 3 additions & 3 deletions Source/Utility/NVGUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ void NVGImage::loadJUCEImage(NVGcontext* context, Image const& image, int const
flags |= withMipmaps ? NVG_IMAGE_GENERATE_MIPMAPS : 0;

if (image.isARGB())
subImage.imageId = nvgCreateImageARGB(nvg, totalWidth, totalHeight, flags | NVG_IMAGE_PREMULTIPLIED, imageData.data);
subImage.imageId = nvgCreateImageARGB_sRGB(nvg, totalWidth, totalHeight, flags, imageData.data);
else if (image.isSingleChannel())
subImage.imageId = nvgCreateImageAlpha(nvg, totalWidth, totalHeight, flags, imageData.data);

Expand Down Expand Up @@ -264,7 +264,7 @@ void NVGImage::loadJUCEImage(NVGcontext* context, Image const& image, int const
flags |= withMipmaps ? NVG_IMAGE_GENERATE_MIPMAPS : 0;

if (image.isARGB())
subImage.imageId = nvgCreateImageARGB(nvg, w, h, flags | NVG_IMAGE_PREMULTIPLIED, imageData.data);
subImage.imageId = nvgCreateImageARGB_sRGB(nvg, w, h, flags, imageData.data);
else if (image.isSingleChannel())
subImage.imageId = nvgCreateImageAlpha(nvg, w, h, flags, imageData.data);

Expand Down Expand Up @@ -378,7 +378,7 @@ void NVGFramebuffer::bind(NVGcontext* ctx, int const width, int const height)
nvg = ctx;
if (fb)
nvgDeleteFramebuffer(fb);
fb = nvgCreateFramebuffer(nvg, width, height, NVG_IMAGE_PREMULTIPLIED);
fb = nvgCreateFramebuffer(nvg, width, height, 0);
fbWidth = width;
fbHeight = height;
}
Expand Down
Loading