ILboolean iCopySubImage(ILimage *Dest, ILimage *Src) { ILimage *DestTemp, *SrcTemp; DestTemp = Dest; SrcTemp = Src; do { il2CopyImageAttr(DestTemp, SrcTemp); DestTemp->Data = (ILubyte*)ialloc(SrcTemp->SizeOfData); if (DestTemp->Data == NULL) { return IL_FALSE; } memcpy(DestTemp->Data, SrcTemp->Data, SrcTemp->SizeOfData); if (SrcTemp->Next) { DestTemp->Next = (ILimage*)icalloc(1, sizeof(ILimage)); if (!DestTemp->Next) { return IL_FALSE; } } else { DestTemp->Next = NULL; } DestTemp = DestTemp->Next; SrcTemp = SrcTemp->Next; } while (SrcTemp); return IL_TRUE; }
//! Copies everything from aSource to aTarget ILboolean ILAPIENTRY il2CopyImage(ILimage* aSource, ILimage* aTarget) { if (aSource == NULL || aTarget == NULL) { il2SetError(IL_ILLEGAL_OPERATION); return IL_FALSE; } il2TexImage(aTarget, aSource->Width, aSource->Height, aSource->Depth, aSource->Bpp, aSource->Format, aSource->Type, aSource->Data); il2CopyImageAttr(aTarget, aSource); return IL_TRUE; }
// Copy data and attributes of aSource into a new image ILimage* ILAPIENTRY il2CloneImage(ILimage* aSource) { if (aSource == NULL) { il2SetError(IL_ILLEGAL_OPERATION); return NULL; } ILimage* newImage = il2GenImage(); il2TexImage(newImage, aSource->Width, aSource->Height, aSource->Depth, aSource->Bpp, aSource->Format, aSource->Type, aSource->Data); il2CopyImageAttr(newImage, aSource); return newImage; }
// Creates a copy of Src and returns it. ILAPI ILimage* ILAPIENTRY il2CopyImage_(ILimage *Src) { ILimage *Dest; if (Src == NULL) { il2SetError(IL_INVALID_PARAM); return NULL; } Dest = il2NewImage(Src->Width, Src->Height, Src->Depth, Src->Bpp, Src->Bpc); if (Dest == NULL) { return NULL; } if (il2CopyImageAttr(Dest, Src) == IL_FALSE) return NULL; memcpy(Dest->Data, Src->Data, Src->SizeOfData); return Dest; }
// Copy data and attributes of the currently bound image into a new image ILAPI ILuint ILAPIENTRY ilCloneCurImage() { ILuint Id; ILimage *CurImage; if (iCurImage == NULL) { il2SetError(IL_ILLEGAL_OPERATION); return 0; } ilGenImages(1, &Id); if (Id == 0) return 0; CurImage = iCurImage; ilBindImage(Id); ilTexImage(CurImage->Width, CurImage->Height, CurImage->Depth, CurImage->Bpp, CurImage->Format, CurImage->Type, CurImage->Data); il2CopyImageAttr(iCurImage, CurImage); iCurImage = CurImage; return Id; }