Ticket #1840: interactive.diff
File interactive.diff, 2.7 KB (added by , 18 years ago) |
---|
-
mythtv/libs/libmythtv/mhi.cpp
627 627 } 628 628 629 629 // Draw a rectangle. This is complicated if we want to get transparency right. 630 void MHIContext::DrawRect(int xPos, int yPos, int width, int height, 631 MHRgba colour) 630 void MHIContext::DrawRect(int xPos, int yPos, int width, int height, MHRgba colour) 632 631 { 633 632 if (colour.alpha() == 0 || height == 0 || width == 0) 634 633 return; // Fully transparent 634 QRgb qColour = qRgba(colour.red(), colour.green(), colour.blue(), colour.alpha()); 635 QRgb qTransparent = qRgba(0,0,0,0); 635 636 636 QRgb qColour = qRgba(colour.red(), colour.green(), 637 colour.blue(), colour.alpha()); 637 int scaledxPos = xPos * GetWidth() / MHIContext::StdDisplayWidth; 638 int scaledyPos = yPos * GetHeight() / MHIContext::StdDisplayHeight; 639 int xboundary = scaledxPos % 2; 640 int yboundary = scaledyPos % 2; 638 641 639 // This is a bit of a mess: we should be able to create a rectangle object.640 // Scale the image to the current display size641 642 int scaledWidth = width * GetWidth() / MHIContext::StdDisplayWidth; 642 643 int scaledHeight = height * GetHeight() / MHIContext::StdDisplayHeight; 644 645 if (xboundary) 646 { 647 scaledxPos --; 648 scaledWidth ++; 649 } 650 if (yboundary) 651 { 652 scaledyPos --; 653 scaledHeight ++; 654 } 655 643 656 QImage qImage(scaledWidth, scaledHeight, 32); 644 657 qImage.setAlphaBuffer(true); 645 646 // As far as I can tell this is the only way to draw with an 647 // intermediate transparency. 648 for (int i = 0; i < scaledHeight; i++) 658 if (xboundary) 649 659 { 660 for (int i = 0; i < scaledHeight; i++) 661 { 662 qImage.setPixel(0, i, qTransparent); 663 } 664 } 665 if (yboundary) 666 { 650 667 for (int j = 0; j < scaledWidth; j++) 651 668 { 669 qImage.setPixel(j, 0, qTransparent); 670 } 671 } 672 // As far as I can tell this is the only way to draw with an intermediate transparency. 673 for (int i = yboundary; i < scaledHeight; i++) 674 { 675 for (int j = xboundary; j < scaledWidth; j++) 676 { 652 677 qImage.setPixel(j, i, qColour); 653 678 } 654 679 } 655 656 680 AddToDisplay(qImage, 657 xPos * GetWidth() / MHIContext::StdDisplayWidth,658 yPos * GetHeight() / MHIContext::StdDisplayHeight);681 scaledxPos, 682 scaledyPos); 659 683 } 660 684 685 661 686 // Draw an image at the specified position. 662 687 // Generally the whole of the image is drawn but sometimes the 663 688 // image may be clipped. x and y define the origin of the bitmap