| 1507 | } |
| 1508 | |
| 1509 | Texture* PSDReader::LoadLayerTexture(int layerIdx, int* ofsX, int* ofsY) // -1 = composited image |
| 1510 | { |
| 1511 | if ((layerIdx < 0) || (layerIdx >= (int) mPSDLayerInfoVector.size())) |
| 1512 | return NULL; |
| 1513 | |
| 1514 | //TODO: This is a special case for flattening here, just on the first layer... |
| 1515 | PSDLayerInfo* prevLayer = (layerIdx == 1) ? mPSDLayerInfoVector[layerIdx - 1] : NULL; |
| 1516 | if (prevLayer != NULL) |
| 1517 | { |
| 1518 | if (prevLayer->mBits == NULL) |
| 1519 | prevLayer->ReadData(); |
| 1520 | } |
| 1521 | |
| 1522 | PSDLayerInfo* aLayer = mPSDLayerInfoVector[layerIdx]; |
| 1523 | if (aLayer->mBits == NULL) |
| 1524 | aLayer->ReadData(); |
| 1525 | |
| 1526 | ImageData* anImageData = aLayer; |
| 1527 | |
| 1528 | anImageData = aLayer->mImageEffects->FlattenInto(prevLayer, aLayer, aLayer, NULL, NULL); |
| 1529 | |
| 1530 | Texture* texture = gBFApp->mRenderDevice->LoadTexture(anImageData, false); |
| 1531 | *ofsX = anImageData->mX; |
| 1532 | *ofsY = anImageData->mY; |
| 1533 | if (anImageData != aLayer) |
| 1534 | delete anImageData; |
| 1535 | return texture; |
| 1536 | } |
| 1537 | |
| 1538 | typedef std::vector<PSDLayerInfo*> PSDLayerVector; |
| 1539 | typedef std::map<int, PSDLayerVector> LayerInfoMap; |
no test coverage detected