MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / GetBest

Method GetBest

rEFIt_UEFI/libeg/XIcon.cpp:249–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247}
248
249XImage* XIcon::GetBest(bool night, bool *free)
250{
251#if 1
252 if (ImageSVG) {
253 NSVGimage* sImage = (NSVGimage*)ImageSVGnight;
254 if (!night || !ImageSVGnight) sImage = (NSVGimage*)ImageSVG;
255 float Scale = sImage->scale;
256 NSVGrasterizer* rast = nsvgCreateRasterizer();
257 float Height = sImage->height * Scale;
258 float Width = sImage->width * Scale;
259 int iWidth = (int)(Width + 0.5f);
260 int iHeight = (int)(Height + 0.5f);
261 XImage* NewImage = new XImage(iWidth, iHeight); //TODO creating new XImage we have to delete it after use
262 if (sImage->shapes == NULL) {
263 if (free) *free = true;
264 return NewImage;
265 }
266 float bounds[4];
267 nsvg__imageBounds(sImage, bounds);
268
269 float tx = 0.f, ty = 0.f;
270 float realWidth = (bounds[2] - bounds[0]) * Scale;
271 float realHeight = (bounds[3] - bounds[1]) * Scale;
272 tx = (Width - realWidth) * 0.5f;
273 ty = (Height - realHeight) * 0.5f;
274
275 nsvgRasterize(rast, sImage, tx, ty, Scale, Scale, (UINT8*)NewImage->GetPixelPtr(0,0), iWidth, iHeight, iWidth*4);
276 nsvgDeleteRasterizer(rast);
277// if (night) ImageNight = *NewImage;
278// else Image = *NewImage;
279// delete NewImage;
280 if (free) *free = true;
281 return NewImage;
282 }
283#endif
284 XImage* RetImage = (night && !ImageNight.isEmpty())? &ImageNight : &Image;
285 if (free) *free = false;
286 return RetImage;
287}
288
289
290

Callers 7

GraphicsMenuStyleMethod · 0.80
DrawMainMenuLabelMethod · 0.80
DrawMainMenuEntryMethod · 0.80
FillByDirMethod · 0.80
InitBarMethod · 0.80
ParseSVGXThemeMethod · 0.80
MouseBirthMethod · 0.80

Calls 6

nsvgCreateRasterizerFunction · 0.85
nsvg__imageBoundsFunction · 0.85
nsvgRasterizeFunction · 0.85
nsvgDeleteRasterizerFunction · 0.85
GetPixelPtrMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected