Taken from http://www-classic.be.com/aboutbe/benewsletter/volume_III/Issue2.html#Insight Hope they don't mind too much. =]
| 433 | // http://www-classic.be.com/aboutbe/benewsletter/volume_III/Issue2.html#Insight |
| 434 | // Hope they don't mind too much. =] |
| 435 | ILboolean ILAPIENTRY iluWave(ILfloat Angle) |
| 436 | { |
| 437 | ILint Delta; |
| 438 | ILuint y; |
| 439 | ILubyte *DataPtr, *TempBuff; |
| 440 | |
| 441 | iluCurImage = ilGetCurImage(); |
| 442 | if (iluCurImage == NULL) { |
| 443 | ilSetError(ILU_ILLEGAL_OPERATION); |
| 444 | return IL_FALSE; |
| 445 | } |
| 446 | |
| 447 | TempBuff = (ILubyte*)ialloc(iluCurImage->SizeOfData); |
| 448 | if (TempBuff == NULL) { |
| 449 | return IL_FALSE; |
| 450 | } |
| 451 | |
| 452 | for (y = 0; y < iluCurImage->Height; y++) { |
| 453 | Delta = (ILint) |
| 454 | (30 * sin((10 * Angle + y) * IL_DEGCONV) + |
| 455 | 15 * sin(( 7 * Angle + 3 * y) * IL_DEGCONV)); |
| 456 | |
| 457 | DataPtr = iluCurImage->Data + y * iluCurImage->Bps; |
| 458 | |
| 459 | if (Delta < 0) { |
| 460 | Delta = -Delta; |
| 461 | memcpy(TempBuff, DataPtr, iluCurImage->Bpp * Delta); |
| 462 | memcpy(DataPtr, DataPtr + iluCurImage->Bpp * Delta, iluCurImage->Bpp * (iluCurImage->Width - Delta)); |
| 463 | memcpy(DataPtr + iluCurImage->Bpp * (iluCurImage->Width - Delta), TempBuff, iluCurImage->Bpp * Delta); |
| 464 | } |
| 465 | else if (Delta > 0) { |
| 466 | memcpy(TempBuff, DataPtr, iluCurImage->Bpp * (iluCurImage->Width - Delta)); |
| 467 | memcpy(DataPtr, DataPtr + iluCurImage->Bpp * (iluCurImage->Width - Delta), iluCurImage->Bpp * Delta); |
| 468 | memcpy(DataPtr + iluCurImage->Bpp * Delta, TempBuff, iluCurImage->Bpp * (iluCurImage->Width - Delta)); |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | ifree(TempBuff); |
| 473 | |
| 474 | return IL_TRUE; |
| 475 | } |
| 476 | |
| 477 | |
| 478 | // Swaps the colour order of the current image (rgb(a)->bgr(a) or vice-versa). |
nothing calls this directly
no test coverage detected