MCPcopy Create free account
hub / github.com/CruiserOne/Astrolog / FBmpDrawBack

Function FBmpDrawBack

xdevice.cpp:563–665  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

561// -XI switch features.
562
563flag FBmpDrawBack(Bitmap *bDest)
564{
565 Bitmap *b = &gi.bmpBack, *b2 = &gi.bmpBack2;
566 int nTrans, x, y, x1, y1, x2, y2, x3, y3, x4, y4, nR, nG, nB, nRT, nGT, nBT;
567 byte *pb, *pb2;
568 KV kv;
569 static KV kvLast = -1;
570 static int nTransLast = 0, xLast = 0, yLast = 0;
571
572 // Don't draw background if user doesn't want to.
573 if (!gs.fBackDraw || !gi.fBmp)
574 return fFalse;
575
576 // Don't draw background if entire chart will be covered with world map.
577 if (gi.bmpWorld.rgb != NULL &&
578 (gi.nMode == gAstroGraph || (gi.nMode == gWorldMap && !gs.fMollweide)))
579 return fFalse;
580
581 // Don't do anything if bitmap empty or transparent enough to be invisible.
582 nTrans = (int)(gs.rBackPct * 256.0 / 100.0);
583 if (b->rgb == NULL || nTrans <= 0)
584 return fFalse;
585
586 // Cache bitmap with proper percentage blend with current background color.
587 kv = KvFromKi(gi.kiOff);
588 if (b2->x != b->x || b2->y != b->y || kv != kvLast || nTrans != nTransLast) {
589 if (!FAllocateBmp(b2, b->x, b->y))
590 return fFalse;
591 kvLast = kv;
592 nTransLast = nTrans;
593 nR = RgbR(kv); nG = RgbG(kv); nB = RgbB(kv);
594 for (y = 0; y < b->y; y++) {
595 pb = _PbXY(b, 0, y);
596 pb2 = _PbXY(b2, 0, y);
597 for (x = 0; x < b->x; x++) {
598 _GetRGB(pb, &nRT, &nGT, &nBT);
599 nRT = nR + ((nRT - nR) * nTrans >> 8);
600 nGT = nG + ((nGT - nG) * nTrans >> 8);
601 nBT = nB + ((nBT - nB) * nTrans >> 8);
602 _SetRGB(pb2, nRT, nGT, nBT);
603 pb += cbPixelK; pb2 += cbPixelK;
604 }
605 }
606 xLast = yLast = 0;
607 }
608
609 // Determine source (on bitmap) and destination (on chart) rectangles.
610 x1 = y1 = x3 = y3 = 0;
611 x2 = gs.xWin; y2 = gs.yWin;
612 x4 = b2->x; y4 = b2->y;
613 if (gs.nBackOrient < 0) {
614 if ((real)x2 / (real)y2 > (real)x4 / (real)y4) {
615 x2 = y2 * x4 / y4;
616 x1 = (gs.xWin - x2) >> 1;
617 } else {
618 y2 = x2 * y4 / x4;
619 y1 = (gs.yWin - y2) >> 1;
620 }

Callers 3

DrawChartXFunction · 0.85
FRedrawFunction · 0.85
FBmpDrawMapFunction · 0.85

Calls 7

FAllocateBmpFunction · 0.85
_PbXYFunction · 0.85
_GetRGBFunction · 0.85
_SetRGBFunction · 0.85
BmpCopyBlockFunction · 0.85
PrintErrorFunction · 0.85
BmpCopyToWinFunction · 0.85

Tested by

no test coverage detected