MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / getColor

Method getColor

Engine/source/gfx/bitmap/gBitmap.cpp:768–811  ·  view source on GitHub ↗

--------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

766
767//--------------------------------------------------------------------------
768bool GBitmap::getColor(const U32 x, const U32 y, ColorI& rColor) const
769{
770 if (x >= mWidth || y >= mHeight)
771 return false;
772
773 const U8* pLoc = getAddress(x, y);
774
775 switch (mInternalFormat) {
776 case GFXFormatA8:
777 case GFXFormatL8:
778 rColor.set( *pLoc, *pLoc, *pLoc, *pLoc );
779 break;
780 case GFXFormatL16:
781 rColor.set(U8(U16((pLoc[0] << 8) + pLoc[1])), 0, 0, 0);
782 case GFXFormatR8G8B8:
783 case GFXFormatR8G8B8X8:
784 rColor.set( pLoc[0], pLoc[1], pLoc[2], 255 );
785 break;
786
787 case GFXFormatR8G8B8A8:
788 rColor.set( pLoc[0], pLoc[1], pLoc[2], pLoc[3] );
789 break;
790
791 case GFXFormatR5G5B5A1:
792#if defined(TORQUE_OS_MAC)
793 rColor.set( (*((U16*)pLoc) >> 0) & 0x1F,
794 (*((U16*)pLoc) >> 5) & 0x1F,
795 (*((U16*)pLoc) >> 10) & 0x1F,
796 ((*((U16*)pLoc) >> 15) & 0x01) ? 255 : 0 );
797#else
798 rColor.set( *((U16*)pLoc) >> 11,
799 (*((U16*)pLoc) >> 6) & 0x1f,
800 (*((U16*)pLoc) >> 1) & 0x1f,
801 (*((U16*)pLoc) & 1) ? 255 : 0 );
802#endif
803 break;
804
805 default:
806 AssertFatal(false, "Bad internal format");
807 return false;
808 }
809
810 return true;
811}
812
813
814//--------------------------------------------------------------------------

Callers 15

buildPolyListMethod · 0.45
_convertToVertexDataMethod · 0.45
resolveColorMethod · 0.45
resolveLightColorFunction · 0.45
resolveTransparencyMethod · 0.45
getBitmapModulationMethod · 0.45
_scoreLightsMethod · 0.45
_update4LightConstsMethod · 0.45
_scoreLightsMethod · 0.45
setLightParametersMethod · 0.45
setShaderParamsMethod · 0.45

Calls 1

setMethod · 0.45

Tested by

no test coverage detected