bitmapex.cxx (5f27b83c) bitmapex.cxx (ff0f521c)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 1186 unchanged lines hidden (view full) ---

1195 }
1196 else
1197 {
1198 return BitmapEx(aChangedBitmap);
1199 }
1200 }
1201}
1202
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 1186 unchanged lines hidden (view full) ---

1195 }
1196 else
1197 {
1198 return BitmapEx(aChangedBitmap);
1199 }
1200 }
1201}
1202
1203// -----------------------------------------------------------------------------
1204
1205BitmapEx VCL_DLLPUBLIC createBlendFrame(
1206 const Size& rSize,
1207 sal_uInt8 nAlpha,
1208 Color aColorTopLeft,
1209 Color aColorBottomRight)
1210{
1211 const sal_uInt32 nW(rSize.Width());
1212 const sal_uInt32 nH(rSize.Height());
1213
1214 if(nW || nH)
1215 {
1216 Color aColTopRight(aColorTopLeft);
1217 Color aColBottomLeft(aColorTopLeft);
1218 const sal_uInt32 nDE(nW + nH);
1219
1220 aColTopRight.Merge(aColorBottomRight, 255 - sal_uInt8((nW * 255) / nDE));
1221 aColBottomLeft.Merge(aColorBottomRight, 255 - sal_uInt8((nH * 255) / nDE));
1222
1223 return createBlendFrame(rSize, nAlpha, aColorTopLeft, aColTopRight, aColorBottomRight, aColBottomLeft);
1224 }
1225
1226 return BitmapEx();
1227}
1228
1229BitmapEx VCL_DLLPUBLIC createBlendFrame(
1230 const Size& rSize,
1231 sal_uInt8 nAlpha,
1232 Color aColorTopLeft,
1233 Color aColorTopRight,
1234 Color aColorBottomRight,
1235 Color aColorBottomLeft)
1236{
1237 static Size aLastSize(0, 0);
1238 static sal_uInt8 nLastAlpha(0);
1239 static Color aLastColorTopLeft(COL_BLACK);
1240 static Color aLastColorTopRight(COL_BLACK);
1241 static Color aLastColorBottomRight(COL_BLACK);
1242 static Color aLastColorBottomLeft(COL_BLACK);
1243 static BitmapEx aLastResult;
1244
1245 if(aLastSize == rSize
1246 && nLastAlpha == nAlpha
1247 && aLastColorTopLeft == aLastColorTopLeft
1248 && aLastColorTopRight == aLastColorTopRight
1249 && aLastColorBottomRight == aLastColorBottomRight
1250 && aLastColorBottomLeft == aLastColorBottomLeft)
1251 {
1252 return aLastResult;
1253 }
1254
1255 aLastSize = rSize;
1256 nLastAlpha = nAlpha;
1257 aLastColorTopLeft = aLastColorTopLeft;
1258 aLastColorTopRight = aLastColorTopRight;
1259 aLastColorBottomRight = aLastColorBottomRight;
1260 aLastColorBottomLeft = aLastColorBottomLeft;
1261 aLastResult.Clear();
1262
1263 const long nW(rSize.Width());
1264 const long nH(rSize.Height());
1265
1266 if(nW && nH)
1267 {
1268 sal_uInt8 aEraseTrans(0xff);
1269 Bitmap aContent(rSize, 24);
1270 AlphaMask aAlpha(rSize, &aEraseTrans);
1271
1272 aContent.Erase(COL_BLACK);
1273
1274 BitmapWriteAccess* pContent = aContent.AcquireWriteAccess();
1275 BitmapWriteAccess* pAlpha = aAlpha.AcquireWriteAccess();
1276
1277 if(pContent && pAlpha)
1278 {
1279 long x(0);
1280 long y(0);
1281
1282 // x == 0, y == 0
1283 pContent->SetPixel(y, x, aColorTopLeft);
1284 pAlpha->SetPixelIndex(y, x, nAlpha);
1285
1286 for(x = 1; x < nW - 1; x++) // y == 0
1287 {
1288 Color aMix(aColorTopLeft);
1289
1290 aMix.Merge(aColorTopRight, 255 - sal_uInt8((x * 255) / nW));
1291 pContent->SetPixel(y, x, aMix);
1292 pAlpha->SetPixelIndex(y, x, nAlpha);
1293 }
1294
1295 // x == nW - 1, y == 0
1296 pContent->SetPixel(y, x, aColorTopRight);
1297 pAlpha->SetPixelIndex(y, x, nAlpha);
1298
1299 for(y = 1; y < nH - 1; y++) // x == 0 and nW - 1
1300 {
1301 Color aMixA(aColorTopLeft);
1302 Color aMixB(aColorTopRight);
1303
1304 aMixA.Merge(aColorBottomLeft, 255 - sal_uInt8((y * 255) / nH));
1305 pContent->SetPixel(y, 0, aMixA);
1306 pAlpha->SetPixelIndex(y, 0, nAlpha);
1307
1308 aMixB.Merge(aColorBottomRight, 255 - sal_uInt8((y * 255) / nH));
1309 pContent->SetPixel(y, nW - 1, aMixB);
1310 pAlpha->SetPixelIndex(y, nW - 1, nAlpha);
1311 }
1312
1313 x = 0; // x == 0, y == nH - 1
1314 pContent->SetPixel(y, x, aColorBottomLeft);
1315 pAlpha->SetPixelIndex(y, x, nAlpha);
1316
1317 for(x = 1; x < nW - 1; x++) // y == nH - 1
1318 {
1319 Color aMix(aColorBottomLeft);
1320
1321 aMix.Merge(aColorBottomRight, 255 - sal_uInt8(((x - 0)* 255) / nW));
1322 pContent->SetPixel(y, x, aMix);
1323 pAlpha->SetPixelIndex(y, x, nAlpha);
1324 }
1325
1326 // x == nW - 1, y == nH - 1
1327 pContent->SetPixel(y, x, aColorBottomRight);
1328 pAlpha->SetPixelIndex(y, x, nAlpha);
1329
1330 aContent.ReleaseAccess(pContent);
1331 aAlpha.ReleaseAccess(pAlpha);
1332
1333 aLastResult = BitmapEx(aContent, aAlpha);
1334 }
1335 else
1336 {
1337 if(pContent)
1338 {
1339 aContent.ReleaseAccess(pContent);
1340 }
1341
1342 if(pAlpha)
1343 {
1344 aAlpha.ReleaseAccess(pAlpha);
1345 }
1346 }
1347 }
1348
1349 return aLastResult;
1350}
1351
1203// ------------------------------------------------------------------
1204// eof
1352// ------------------------------------------------------------------
1353// eof