Ticket #1840: interactive.diff

File interactive.diff, 2.7 KB (added by anonymous, 18 years ago)
  • mythtv/libs/libmythtv/mhi.cpp

     
    627627}
    628628
    629629// 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)
     630void MHIContext::DrawRect(int xPos, int yPos, int width, int height, MHRgba colour)
    632631{
    633632    if (colour.alpha() == 0 || height == 0 || width == 0)
    634633        return; // Fully transparent
     634    QRgb qColour = qRgba(colour.red(), colour.green(), colour.blue(), colour.alpha());
     635    QRgb qTransparent = qRgba(0,0,0,0);
    635636
    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;
    638641
    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 size
    641642    int scaledWidth = width * GetWidth() / MHIContext::StdDisplayWidth;
    642643    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
    643656    QImage qImage(scaledWidth, scaledHeight, 32);
    644657    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)
    649659    {
     660        for (int i = 0; i < scaledHeight; i++)
     661        {
     662             qImage.setPixel(0, i, qTransparent);
     663        }
     664    }
     665    if (yboundary)
     666    {
    650667        for (int j = 0; j < scaledWidth; j++)
    651668        {
     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        {
    652677            qImage.setPixel(j, i, qColour);
    653678        }
    654679    }
    655 
    656680    AddToDisplay(qImage,
    657         xPos * GetWidth() / MHIContext::StdDisplayWidth,
    658         yPos * GetHeight() / MHIContext::StdDisplayHeight);
     681        scaledxPos,
     682        scaledyPos);
    659683}
    660684
     685
    661686// Draw an image at the specified position.
    662687// Generally the whole of the image is drawn but sometimes the
    663688// image may be clipped. x and y define the origin of the bitmap