| 371 | } |
| 372 | |
| 373 | bool PSDReader::ReadEffectGradient(PSDDescriptor* descriptor, ImageGradient* colorGradient) |
| 374 | { |
| 375 | if (descriptor->Contains("Grad")) |
| 376 | { |
| 377 | PSDDescriptor* gradDesc = descriptor->GetDescriptor("Grad"); |
| 378 | int gridF = gradDesc->Get("GrdF")->GetMulticharInt(); // CstS |
| 379 | double intr = gradDesc->Get("Intr")->mDouble; |
| 380 | int trns = gradDesc->Get("Trns")->mInteger; |
| 381 | |
| 382 | PSDValue* colors = gradDesc->Get("Clrs"); |
| 383 | for (int colorIdx = 0; colorIdx < colors->mInteger; colorIdx++) |
| 384 | { |
| 385 | PSDDescriptor* colorDataDesc = colors->mList[colorIdx].mDescriptor; |
| 386 | |
| 387 | PSDDescriptor* aColorDesc = colorDataDesc->GetDescriptor("Clr "); |
| 388 | int vals[3]; |
| 389 | vals[0] = (int) aColorDesc->Get("Rd ")->mDouble; |
| 390 | vals[1] = (int) aColorDesc->Get("Grn ")->mDouble; |
| 391 | vals[2] = (int) aColorDesc->Get("Bl ")->mDouble; |
| 392 | |
| 393 | int loc = colorDataDesc->Get("Lctn")->mInteger; |
| 394 | int mdPn = colorDataDesc->Get("Mdpn")->mInteger; |
| 395 | int aType = colorDataDesc->Get("Type")->GetMulticharInt(); |
| 396 | |
| 397 | for (int i = 0; i < 3; i++) |
| 398 | { |
| 399 | ImageGradientPoint pt; |
| 400 | pt.mX = (float) loc; |
| 401 | pt.mValue = vals[i]; |
| 402 | |
| 403 | if ((colorGradient[i].mPoints.size() != 0) && (colorGradient[i].mPoints.back().mX == pt.mX)) |
| 404 | colorGradient[i].mPoints.back() = pt; |
| 405 | else |
| 406 | colorGradient[i].mPoints.push_back(pt); |
| 407 | } |
| 408 | } |
| 409 | for (int i = 0; i < 4; i++) |
| 410 | { |
| 411 | colorGradient[i].mXSize = 4096; |
| 412 | colorGradient[i].mSmoothness = (float) intr / 4096.0f; |
| 413 | } |
| 414 | |
| 415 | PSDValue* transDesc = gradDesc->Get("Trns"); |
| 416 | for (int transIdx = 0; transIdx < transDesc->mInteger; transIdx++) |
| 417 | { |
| 418 | ImageGradientPoint pt; |
| 419 | |
| 420 | PSDDescriptor* transDataDesc = transDesc->mList[transIdx].mDescriptor; |
| 421 | |
| 422 | int loc = transDataDesc->Get("Lctn")->mInteger; |
| 423 | double opacity = transDataDesc->Get("Opct")->mDouble; |
| 424 | |
| 425 | pt.mX = (float) loc; |
| 426 | pt.mValue = (int) (opacity * 255 / 100.0f + 0.5f); |
| 427 | colorGradient[3].mPoints.push_back(pt); |
| 428 | } |
| 429 | |
| 430 | return true; |
nothing calls this directly
no test coverage detected