Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Private Attributes
SelectionImageService Class Reference
Inheritance diagram for SelectionImageService:
Inheritance graph
[legend]
Collaboration diagram for SelectionImageService:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SelectionImageService ()
virtual ~SelectionImageService ()
void reset ()
 the current image is marked as invalid
void getImage (in short selectionValue, out imgIContainer container)
 retrieve the image for alpha blending

Private Member Functions

nsresult CreateImage (nscolor aImageColor, imgIContainer *aContainer)

Private Attributes

nsCOMPtr< imgIContainermContainer
nsCOMPtr< imgIContainermDisabledContainer

Detailed Description

Definition at line 270 of file nsFrame.cpp.


Constructor & Destructor Documentation

Definition at line 285 of file nsFrame.cpp.

{
}

Definition at line 289 of file nsFrame.cpp.

{
}

Member Function Documentation

nsresult SelectionImageService::CreateImage ( nscolor  aImageColor,
imgIContainer aContainer 
) [private]

Definition at line 340 of file nsFrame.cpp.

{
  if (aContainer)
  {
    nsresult result = aContainer->Init(SEL_IMAGE_WIDTH,SEL_IMAGE_HEIGHT,nsnull);
    if (NS_SUCCEEDED(result))
    {
      nsCOMPtr<gfxIImageFrame> image = do_CreateInstance("@mozilla.org/gfx/image/frame;2",&result);
      if (NS_SUCCEEDED(result) && image)
      {
        image->Init(0, 0, SEL_IMAGE_WIDTH, SEL_IMAGE_HEIGHT, gfxIFormats::RGB_A8, 24);
        aContainer->AppendFrame(image);

        PRUint32 bpr, abpr;
        image->GetImageBytesPerRow(&bpr);
        image->GetAlphaBytesPerRow(&abpr);

        //its better to temporarily go after heap than put big data on stack
        unsigned char *row_data = (unsigned char *)malloc(bpr);
        if (!row_data)
          return NS_ERROR_OUT_OF_MEMORY;
        unsigned char *alpha = (unsigned char *)malloc(abpr);
        if (!alpha)
        {
          free (row_data);
          return NS_ERROR_OUT_OF_MEMORY;
        }
        unsigned char *data = row_data;

        PRInt16 i;
        for (i = 0; i < SEL_IMAGE_WIDTH; i++)
        {
#if defined(XP_WIN) || defined(XP_OS2)
          *data++ = NS_GET_B(aImageColor);
          *data++ = NS_GET_G(aImageColor);
          *data++ = NS_GET_R(aImageColor);
#else
#if defined(XP_MAC) || defined(XP_MACOSX)
          *data++ = 0;
#endif
          *data++ = NS_GET_R(aImageColor);
          *data++ = NS_GET_G(aImageColor);
          *data++ = NS_GET_B(aImageColor);
#endif
        }

        memset((void *)alpha, SEL_ALPHA_AMOUNT, abpr);

        for (i = 0; i < SEL_IMAGE_HEIGHT; i++)
        {
          image->SetAlphaData(alpha, abpr, i*abpr);
          image->SetImageData(row_data,  bpr, i*bpr);
        }
        free(row_data);
        free(alpha);
        return NS_OK;
      }
    } 
  }
  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

void nsISelectionImageService::getImage ( in short  selectionValue,
out imgIContainer  container 
) [inherited]

retrieve the image for alpha blending

the current image is marked as invalid


Member Data Documentation

Definition at line 279 of file nsFrame.cpp.

Definition at line 280 of file nsFrame.cpp.


The documentation for this class was generated from the following file: