shizhoubo[OOoFrm] schrieb: > Hi Carsten, > > I have changed the source. when I test, I found a question and tried > solve it with many methods, but I cant solve it. the question as following: > when I create a bitmap sized 16*16 with Bitmap constructor, the bitmap > created always is black, > why ? I tried solve it with many methods, sorry I cant. Could you give > me some helps? Hi Shi zhoubo,
I checked your changes and was able to reproduce your problems. The problem with the missing transparency is based on the fact that we used the wrong VirtualDevice ctor. I changed the code and the scaling method works without any problem. Please check my changes and try to understand it. We can discuss it tomorrow in our IRC meeting. Regards, Carsten ------ //AutoScaleBitmap() added for issue83555 BitmapEx SvxIconSelectorDialog::AutoScaleBitmap( BitmapEx & aBitmap, const long aStandardSize) { Point aEmptyPoint(0,0); sal_Int32 imgNewWidth = 0; sal_Int32 imgNewHeight = 0; double imgposX = 0; double imgposY = 0; BitmapEx aRet = aBitmap; double imgOldWidth = aRet.GetSizePixel().Width(); double imgOldHeight =aRet.GetSizePixel().Height(); if (imgOldWidth >= aStandardSize || imgOldHeight >= aStandardSize) { if (imgOldWidth >= imgOldHeight) { imgNewWidth = aStandardSize; imgNewHeight = sal_Int32(imgOldHeight / (imgOldWidth / aStandardSize) + 0.5); imgposX = 0; imgposY = (aStandardSize - (imgOldHeight / (imgOldWidth / aStandardSize) + 0.5)) / 2 + 0.5; } else { imgNewHeight = aStandardSize; imgNewWidth = sal_Int32(imgOldWidth / (imgOldHeight / aStandardSize) + 0.5); imgposY = 0; imgposX = (aStandardSize - (imgOldWidth / (imgOldHeight / aStandardSize) + 0.5)) / 2 + 0.5; } Size aScaledSize( imgNewWidth, imgNewHeight ); aRet.Scale( aScaledSize, BMP_SCALE_INTERPOLATE ); } else { imgposX = (aStandardSize - imgOldWidth) / 2 + 0.5; imgposY = (aStandardSize - imgOldHeight) / 2 + 0.5; } Size aStdSize( aStandardSize, aStandardSize ); Rectangle aRect(aEmptyPoint, aStdSize ); VirtualDevice aVirDevice( *Application::GetDefaultDevice(),0,1); aVirDevice.SetOutputSizePixel( aStdSize ); aVirDevice.SetFillColor( COL_TRANSPARENT ); aVirDevice.SetLineColor( COL_TRANSPARENT ); //draw a rect into virDevice aVirDevice.DrawRect( aRect ); Point aPointPixel( (long)imgposX, (long)imgposY ); aVirDevice.DrawBitmapEx( aPointPixel, aRet ); aRet = aVirDevice.GetBitmapEx( aEmptyPoint, aStdSize ); return aRet; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]