see SDK Help:--
CFbsBitmap instances cannot be shared between different threads. They use some shared thread local storage data. If you want to share a bitmap between threads, use Duplicate().
Thanks for advice.I will take care next time onwards.
I hope this might helped you?
Again pasting code below:-
void CMyBitMapClass::CopyFbsBitmapL(CFbsBitmap * orig, CFbsBitmap * dest)
{
TSize s = orig->SizeInPixels();
User::LeaveIfError(dest->Create(s, orig->DisplayMode()));
Its just a bit low-level, nothing really that weird, it does not depend on any undocumented features or anything, and it does it as efficiently as the current available API:s allow you to, and it takes all precautions needed.
Even in an object oriented language you will have to move memory around sometimes, but sure, the "OOP way" would be to overload operator=() or something, and allow you to do:
*dstbmp = *srcbmp;
...or something...
But I think they chose to not include a function like that, to avoid that less avid programmers copy their bitmaps unnecessarily, when they could have used Duplicate() instead and saved a lot of memory.
Its not really that often you have to copy bitmaps...
And you can also achieve it by using CFbsBitGc, CFbsBitmapDevice and BitBlt (this also a lot faster then the TBitmapUtil way)
Forum posts: 231
Hi Sandeepmhptr,
Checkout this:-http://www.newlc.com/topic-3539
hopefully you will solve your problem.
Thanks & Regards,
Md.Khalid Ahmad
Forum posts: 231
you can also do it like this:-
Thanks & Regards,
Md.Khalid Ahmad
Forum posts: 138
hi khalid,
I think some text is missing............... in the two for loops
I think you have used "<" symbol in for loop
type "< " instead.
include a space after the symbol.
else this site does not display anything in the line that follows "<" symbol
Regards!
Forum posts: 11
Why u need that ?
see SDK Help:--
CFbsBitmap instances cannot be shared between different threads. They use some shared thread local storage data. If you want to share a bitmap between threads, use Duplicate().
Forum posts: 231
Hi sandeepmhptr,
Thanks for advice.I will take care next time onwards.
{
I hope this might helped you?
Again pasting code below:-
void CMyBitMapClass::CopyFbsBitmapL(CFbsBitmap * orig, CFbsBitmap * dest)
{
TSize s = orig->SizeInPixels();
User::LeaveIfError(dest->Create(s, orig->DisplayMode()));
TBitmapUtil orig_util(orig);
TBitmapUtil dest_util(dest);
orig_util.Begin(TPoint(0,0));
dest_util.Begin(TPoint(0,0), orig_util);
TInt xPos;
for (TInt yPos=0;yPos"<"s.iHeight;yPos++)
{
orig_util.SetPos(TPoint(0,yPos));
dest_util.SetPos(TPoint(0,yPos));
for (xPos=0;xPos
dest_util.SetPixel(orig_util);
orig_util.IncXPos();
dest_util.IncXPos();
}
}
orig_util.End();
dest_util.End();
}
Thanks & Regards,
Md.Khalid Ahmad
Forum posts: 138
is there any way to find each row and column of the bitmap also..................????????????
Forum posts: 1419
The above posted code, whilst perfectly correct, it is an extremely slow and roundabout way of copying a bitmap.
If you want an exact copy in a new bitmap (same color format etc) you should use Mem::Copy.
I'd expect it to be somewhere between 10x to 100x as fast:
CFbsBitmap* dstbmp = new (ELeave) CFbsBitmap(); if(KErrNone == dstbmp->Create(aSourceBmp->SizeInPixels(), aSourceBitmap->DisplayMode())) { aSourceBmp->LockHeap(); TInt length = aSourceBmp->SizeInPixels().iHeight * aSourceBitmap->DataStride(); Mem::Copy( dstbmp->DataAddress(), aSourceBmp->DataAddress(), length); aSourceBmp->UnlockHeap(); }Forum posts: 4
Use as
TInt scanlinelenght = iIconBitmap->ScanLineLength(imgWidth,iIconBitmap->DisplayMode());
TInt iBufLength = imgHeight * scanlinelenght;
Mem::Copy(iNewIconBitmap->DataAddress(),iIconBitmap->DataAddress(),iBufLength);
it works
Forum posts: 1321
Is this use of Mem::Copy the "official" way to do it?
I mean, it works alright, but doesn't this fly in the face of all good object-oriented and abstraction-based programming?
I was surprised anyway to see no method that directly copies a bitmap in the desired way.
René Brunner
Forum posts: 1419
official enough
Its just a bit low-level, nothing really that weird, it does not depend on any undocumented features or anything, and it does it as efficiently as the current available API:s allow you to, and it takes all precautions needed.
Even in an object oriented language you will have to move memory around sometimes, but sure, the "OOP way" would be to overload operator=() or something, and allow you to do:
*dstbmp = *srcbmp;
...or something...
But I think they chose to not include a function like that, to avoid that less avid programmers copy their bitmaps unnecessarily, when they could have used Duplicate() instead and saved a lot of memory.
Its not really that often you have to copy bitmaps...
And you can also achieve it by using CFbsBitGc, CFbsBitmapDevice and BitBlt (this also a lot faster then the TBitmapUtil way)