void ResContinuousSound::Serialize(Parcel::ObjStream &pArchive) { if(pArchive.IsWriting()) { pArchive << mNbCopy; pArchive << mDataLen; pArchive.Write(mData, mDataLen); } else { SoundServer::DeleteContinuousSound(mSound); mSound = NULL; delete[]mData; mData = NULL; pArchive >> mNbCopy; pArchive >> mDataLen; mData = new char[mDataLen]; pArchive.Read(mData, mDataLen); mSound = SoundServer::CreateContinuousSound(mData, mNbCopy); } }
void ResBitmap::SubBitmap::Serialize(Parcel::ObjStream &pArchive) { if(pArchive.IsWriting()) { pArchive << mXRes; pArchive << mYRes; pArchive << mXResShiftFactor; pArchive << mYResShiftFactor; pArchive << mHaveTransparent; if (mXRes < 0 || mXRes > MAX_BITMAP_WIDTH || mYRes < 0 || mYRes > MAX_BITMAP_HEIGHT) { throw Parcel::ObjStreamExn( pArchive.GetName(), boost::str(boost::format( "Writing invalid ResBitmap size: %dx%d") % mXRes % mYRes)); } pArchive.Write(mBuffer, static_cast<size_t>(mXRes * mYRes)); } else { delete[] mBuffer; delete[] mColumnPtr; pArchive >> mXRes; pArchive >> mYRes; pArchive >> mXResShiftFactor; pArchive >> mYResShiftFactor; pArchive >> mHaveTransparent; if (mXRes < 0 || mXRes > MAX_BITMAP_WIDTH || mYRes < 0 || mYRes > MAX_BITMAP_HEIGHT) { throw Parcel::ObjStreamExn( pArchive.GetName(), boost::str(boost::format( "Writing invalid ResBitmap size: %dx%d") % mXRes % mYRes)); } auto sz = static_cast<size_t>(mXRes * mYRes); mBuffer = new MR_UInt8[sz]; mColumnPtr = new MR_UInt8 *[mXRes]; MR_UInt8 *lPtr = mBuffer; for(int lCounter = 0; lCounter < mXRes; lCounter++) { mColumnPtr[lCounter] = lPtr; lPtr += mYRes; } pArchive.Read(mBuffer, sz); } }