MCPcopy Create free account
hub / github.com/ddnet/ddnet / CheckImageDivisibility

Method CheckImageDivisibility

src/engine/client/graphics_threaded.cpp:597–633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

595}
596
597bool CGraphics_Threaded::CheckImageDivisibility(const char *pContextName, CImageInfo &Image, int DivX, int DivY, bool AllowResize)
598{
599 dbg_assert(DivX != 0 && DivY != 0, "Passing 0 to this function is not allowed.");
600 bool ImageIsValid = true;
601 bool WidthBroken = Image.m_Width == 0 || (Image.m_Width % DivX) != 0;
602 bool HeightBroken = Image.m_Height == 0 || (Image.m_Height % DivY) != 0;
603 if(WidthBroken || HeightBroken)
604 {
605 SWarning NewWarning;
606 char aContextNameQuoted[128];
607 str_format(aContextNameQuoted, sizeof(aContextNameQuoted), "\"%s\"", pContextName);
608 str_format(NewWarning.m_aWarningMsg, sizeof(NewWarning.m_aWarningMsg),
609 Localize("The width of texture %s is not divisible by %d, or the height is not divisible by %d, which might cause visual bugs."), aContextNameQuoted, DivX, DivY);
610 AddWarning(NewWarning);
611 ImageIsValid = false;
612 }
613
614 if(AllowResize && !ImageIsValid && Image.m_Width > 0 && Image.m_Height > 0)
615 {
616 int NewWidth = DivX;
617 int NewHeight = DivY;
618 if(WidthBroken)
619 {
620 NewWidth = maximum<int>(HighestBit(Image.m_Width), DivX);
621 NewHeight = (NewWidth / DivX) * DivY;
622 }
623 else
624 {
625 NewHeight = maximum<int>(HighestBit(Image.m_Height), DivY);
626 NewWidth = (NewHeight / DivY) * DivX;
627 }
628 ResizeImage(Image, NewWidth, NewHeight);
629 ImageIsValid = true;
630 }
631
632 return ImageIsValid;
633}
634
635bool CGraphics_Threaded::IsImageFormatRgba(const char *pContextName, const CImageInfo &Image)
636{

Callers 8

LoadGameSkinMethod · 0.80
LoadEmoticonsSkinMethod · 0.80
LoadParticlesSkinMethod · 0.80
LoadHudSkinMethod · 0.80
LoadExtrasSkinMethod · 0.80
LoadSkinDataMethod · 0.80
LoadXmasHatMethod · 0.80
LoadBotDecorationMethod · 0.80

Calls 4

str_formatFunction · 0.85
LocalizeFunction · 0.85
HighestBitFunction · 0.85
ResizeImageFunction · 0.85

Tested by

no test coverage detected