public CoreImageInfo(ref CoreDll.adImageInfoW imageInfo) { id = (ulong)imageInfo.id; path = imageInfo.path; size = imageInfo.size; time = imageInfo.time; type = imageInfo.type; width = imageInfo.width; height = imageInfo.height; blockiness = imageInfo.blockiness; blurring = imageInfo.blurring; exifInfo = imageInfo.exifInfo; }
/// <summary> /// Возврашает массив CoreImageInfo содержащихся в переданной группе. /// </summary> /// <param name="groupId"></param> /// <param name="startFrom"></param> /// <param name="size"></param> /// <returns></returns> public CoreImageInfo[] GetImageInfo(int groupId, uint startFrom, uint size) { uint imageInfoSize = GetImageInfoSize(groupId); if (imageInfoSize > startFrom) { object imageInfoObject = new CoreDll.adImageInfoW(); int sizeOfImageInfo = Marshal.SizeOf(imageInfoObject); byte[] buffer = new byte[sizeOfImageInfo * PAGE_SIZE]; size = Math.Min(imageInfoSize - startFrom, size); CoreImageInfo[] imageInfos = new CoreImageInfo[size]; uint pageCount = (uint)(size / PAGE_SIZE + (size % PAGE_SIZE > 0 ? 1 : 0)); for (uint page = 0; page < pageCount; ++page) { UIntPtr[] pStartFrom = new UIntPtr[1]; pStartFrom[0] = new UIntPtr(startFrom + page * PAGE_SIZE); UIntPtr[] pSize = new UIntPtr[1]; pSize[0] = new UIntPtr(PAGE_SIZE); if (m_dll.adImageInfoGetW(m_handle, new IntPtr(groupId), Marshal.UnsafeAddrOfPinnedArrayElement(pStartFrom, 0), Marshal.UnsafeAddrOfPinnedArrayElement(buffer, 0), Marshal.UnsafeAddrOfPinnedArrayElement(pSize, 0)) == CoreDll.Error.Ok) { for (uint i = 0; i < pSize[0].ToUInt32(); ++i) { IntPtr pImageInfo = Marshal.UnsafeAddrOfPinnedArrayElement(buffer, (int)(i * sizeOfImageInfo)); CoreDll.adImageInfoW imageInfo = (CoreDll.adImageInfoW)Marshal.PtrToStructure(pImageInfo, imageInfoObject.GetType()); imageInfos[page * PAGE_SIZE + i] = new CoreImageInfo(ref imageInfo); } } } return(imageInfos); } return(null); }