javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swtimage.cpp
branchRCL_3
changeset 60 6c158198356e
parent 19 04becd199f91
equal deleted inserted replaced
59:e5618cc85d74 60:6c158198356e
    93 CSwtImage* CSwtImage::NewL(CFbsBitmap& aBitmap, CFbsBitmap* aMask,
    93 CSwtImage* CSwtImage::NewL(CFbsBitmap& aBitmap, CFbsBitmap* aMask,
    94                            const TPoint& aTopLeft, TInt aDelayTime, TSwtGifDisposal aDisposalMethod)
    94                            const TPoint& aTopLeft, TInt aDelayTime, TSwtGifDisposal aDisposalMethod)
    95 {
    95 {
    96     CSwtImage* self = new(ELeave) CSwtImage(NULL, NULL);
    96     CSwtImage* self = new(ELeave) CSwtImage(NULL, NULL);
    97     CleanupStack::PushL(self);
    97     CleanupStack::PushL(self);
    98     self->ConstructL(aBitmap, aMask, aTopLeft, aDelayTime, aDisposalMethod);
    98     self->ConstructL(aBitmap, aMask, aTopLeft, aDelayTime, aDisposalMethod, ETrue);
       
    99     CleanupStack::Pop(self);
       
   100     return self;
       
   101 }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // CSwtImage::NewL
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 CSwtImage* CSwtImage::NewL(CFbsBitmap& aBitmap, CFbsBitmap* aMask)
       
   108 {
       
   109     CSwtImage* self = new(ELeave) CSwtImage(NULL, NULL);
       
   110     CleanupStack::PushL(self);
       
   111     self->ConstructL(aBitmap, aMask, TPoint(0, 0), 0, KSwtDisposalUnspecified, EFalse);
    99     CleanupStack::Pop(self);
   112     CleanupStack::Pop(self);
   100     return self;
   113     return self;
   101 }
   114 }
   102 
   115 
   103 // ---------------------------------------------------------------------------
   116 // ---------------------------------------------------------------------------
   261 // ---------------------------------------------------------------------------
   274 // ---------------------------------------------------------------------------
   262 // CSwtImage::ConstructL
   275 // CSwtImage::ConstructL
   263 // ---------------------------------------------------------------------------
   276 // ---------------------------------------------------------------------------
   264 //
   277 //
   265 void CSwtImage::ConstructL(CFbsBitmap& aBitmap, CFbsBitmap* aMask,
   278 void CSwtImage::ConstructL(CFbsBitmap& aBitmap, CFbsBitmap* aMask,
   266                            const TPoint& aTopLeft, TInt aDelayTime, TSwtGifDisposal aDisposalMethod)
   279                            const TPoint& aTopLeft, TInt aDelayTime,
   267 {
   280                            TSwtGifDisposal aDisposalMethod, TBool aBmpOwnExternally)
   268     // Caution: when using this constructor you depend on the external bitmap's lifetime
   281 {
   269     iOwnExternally = ETrue;
   282     // Caution: if true, the object depends on the external bitmap's lifetime
       
   283     iOwnExternally = aBmpOwnExternally;
   270 
   284 
   271     iBitmap = &aBitmap;
   285     iBitmap = &aBitmap;
   272     iMask = aMask;
   286     iMask = aMask;
   273 
   287 
   274     TDisplayMode mode = iBitmap->DisplayMode();
   288     TDisplayMode mode = iBitmap->DisplayMode();
  1598         // NOTE! iScaledBitmapRefs, iScaledBitmaps, iScaledMasks and
  1612         // NOTE! iScaledBitmapRefs, iScaledBitmaps, iScaledMasks and
  1599         // iScaledMasksInverted must always have the same number of entries.
  1613         // iScaledMasksInverted must always have the same number of entries.
  1600         // NOTE! iScaledMasksInverted entries are valid only if
  1614         // NOTE! iScaledMasksInverted entries are valid only if
  1601         // the main mask is monochrome. Otherwise they are NULL
  1615         // the main mask is monochrome. Otherwise they are NULL
  1602         // and iScaledMasks entries should be used instead.
  1616         // and iScaledMasks entries should be used instead.
  1603         iScaledBitmapRefs.Append(0);
  1617         TInt err = KErrNone;
  1604         iScaledBitmaps.Append(bmp);
  1618         TInt appendCount = 0;
  1605         iScaledMasks.Append(mask);
  1619         err = iScaledBitmapRefs.Append(0);
  1606         iScaledMasksInverted.Append(maski);
  1620         if (err == KErrNone)
  1607     }
  1621         {
  1608     else
  1622             ++appendCount;
       
  1623             err = iScaledBitmaps.Append(bmp);
       
  1624         }
       
  1625         if (err == KErrNone)
       
  1626         {
       
  1627             ++appendCount;
       
  1628             err = iScaledMasks.Append(mask);
       
  1629         }
       
  1630         if (err == KErrNone)
       
  1631         {
       
  1632             ++appendCount;
       
  1633             err = iScaledMasksInverted.Append(maski);
       
  1634         }
       
  1635 
       
  1636         if (err)
       
  1637         {
       
  1638             if (appendCount > 0)
       
  1639             {
       
  1640                 iScaledBitmapRefs.Remove(iScaledBitmapRefs.Count() - 1);
       
  1641             }
       
  1642             if (appendCount > 1)
       
  1643             {
       
  1644                 iScaledBitmaps.Remove(iScaledBitmaps.Count() - 1);
       
  1645             }
       
  1646             if (appendCount > 2)
       
  1647             {
       
  1648                 iScaledMasks.Remove(iScaledMasks.Count() - 1);
       
  1649             }
       
  1650 
       
  1651             delete bmp;
       
  1652             bmp = NULL;
       
  1653             delete mask;
       
  1654             mask = NULL;
       
  1655             delete maski;
       
  1656             maski = NULL;
       
  1657         }
       
  1658     }
       
  1659 
       
  1660     if (!bmp)
  1609     {
  1661     {
  1610         // In the case of no memory or whatever
  1662         // In the case of no memory or whatever
  1611         ASSERT(EFalse);
  1663         ASSERT(EFalse);
  1612         bmp = &GetBitmap();
  1664         bmp = &GetBitmap();
  1613     }
  1665     }