if you are sure your enumerable has less than int.MaxValue elements (or long.MaxValue if you use a long index), you can:ĭon't use foreach, and use a for loop, converting your IEnumerable to a generic enumerable first: var genericList = list.Cast() įor(int i = 0 i ().Select((r, i) => new )) You can't, because IEnumerable doesn't have an index at all. Note that the same basic approach can be used to remap flat images onto any other shape, including 3D surface mapping. This is essentially a filtering operation, so you lose some resolution - but the result looks a LOT better to the human eye it does a much better job of retaining small details and avoids creating straight-line artifacts which humans find objectionable. The better solution involves calculating the corresponding source coordinate without rounding, and then using its fractional position between pixels to compute an appropriate average of the (typically) four pixels surrounding that location. Make sure your copying iterates through the destination space, so all pixels are covered there even if they're painted more than once, rather than thru the source which may skip pixels in the output. The simple solution is to just remap coordinates from the original to the final image, copying pixels from one coordinate space to the other, rounding off as necessary - which may result in some pixels being copied several times adjacent to each other, and other pixels being skipped, depending on whether you're stretching or shrinking (or both) in either dimension.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |