本文整理汇总了C#中TexImage.Rescale方法的典型用法代码示例。如果您正苦于以下问题:C# TexImage.Rescale方法的具体用法?C# TexImage.Rescale怎么用?C# TexImage.Rescale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TexImage
的用法示例。
在下文中一共展示了TexImage.Rescale方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Rescale
/// <summary>
/// Rescales the specified image.
/// </summary>
/// <remarks>
/// The MipmapCount will be reset to 1 after this operation
/// </remarks>
/// <param name="image">The image.</param>
/// <param name="libraryData">The library data.</param>
/// <param name="rescale">The rescale.</param>
private void Rescale(TexImage image, FreeImageTextureLibraryData libraryData, RescalingRequest rescale)
{
int width = rescale.ComputeWidth(image);
int height = rescale.ComputeHeight(image);
Log.Info("Rescaling image to " + width + "x" + height + " with " + rescale.Filter + " ...");
FIBITMAP[] newTab;
if (image.Dimension == TexImage.TextureDimension.Texture3D) // in case of 3D Texture, we must rescale each slice of the top mipmap level
{
newTab = new FIBITMAP[image.ArraySize * image.FaceCount * image.Depth];
int curDepth;
int nbSubImageWithMipMapPerArrayMemeber = 0; // calculating the number of sub images we have to jump to reach the next top level mipmap of the next array member
curDepth = image.Depth;
for (int i = 0; i < image.MipmapCount; ++i)
{
nbSubImageWithMipMapPerArrayMemeber += curDepth;
curDepth = curDepth > 1 ? curDepth >>= 1 : curDepth;
}
int ct = 0;
for (int j = 0; j < image.ArraySize; ++j)
{
for (int i = 0; i < image.Depth; ++i)
{
newTab[ct] = FreeImage.Rescale(libraryData.Bitmaps[i + j * nbSubImageWithMipMapPerArrayMemeber], width, height, (FREE_IMAGE_FILTER)rescale.Filter);
++ct;
}
}
}
else
{
newTab = new FIBITMAP[image.ArraySize];
int ct = 0;
for (int i = 0; i < libraryData.Bitmaps.Length; i += image.MipmapCount)
{
newTab[ct] = FreeImage.Rescale(libraryData.Bitmaps[i], width, height, (FREE_IMAGE_FILTER)rescale.Filter);
++ct;
}
}
for (int i = 0; i < libraryData.Bitmaps.Length; ++i)
{
FreeImage.Unload(libraryData.Bitmaps[i]);
}
libraryData.Bitmaps = newTab;
image.Data = FreeImage.GetBits(newTab[0]);
// Updating image data
image.Rescale(width, height);
int rowPitch, slicePitch;
Tools.ComputePitch(image.Format, width, height, out rowPitch, out slicePitch);
image.RowPitch = rowPitch;
image.SlicePitch = slicePitch;
image.MipmapCount = 1;
image.DataSize = image.SlicePitch * image.ArraySize * image.FaceCount * image.Depth;
}
示例2: Rescale
/// <summary>
/// Rescales the specified image.
/// </summary>
/// <param name="image">The image.</param>
/// <param name="libraryData">The library data.</param>
/// <param name="request">The request.</param>
/// <exception cref="TexLibraryException">Rescaling failed</exception>
private void Rescale(TexImage image, DxtTextureLibraryData libraryData, RescalingRequest request)
{
int width = request.ComputeWidth(image);
int height = request.ComputeHeight(image);
Log.Info("Rescaling to " + width + "x" + height + " ...");
TEX_FILTER_FLAGS filter;
switch(request.Filter)
{
case Filter.Rescaling.Bilinear:
filter = TEX_FILTER_FLAGS.TEX_FILTER_LINEAR;
break;
case Filter.Rescaling.Bicubic:
filter = TEX_FILTER_FLAGS.TEX_FILTER_CUBIC;
break;
case Filter.Rescaling.Box:
filter = TEX_FILTER_FLAGS.TEX_FILTER_FANT;
break;
case Filter.Rescaling.Nearest:
filter = TEX_FILTER_FLAGS.TEX_FILTER_POINT;
break;
default:
filter = TEX_FILTER_FLAGS.TEX_FILTER_FANT;
break;
}
ScratchImage scratchImage = new ScratchImage();
HRESULT hr = Utilities.Resize(libraryData.DxtImages, libraryData.DxtImages.Length, ref libraryData.Metadata, width, height, filter, scratchImage);
if (hr != HRESULT.S_OK)
{
Log.Error("Rescaling failed: " + hr);
throw new TextureToolsException("Rescaling failed: " + hr);
}
// Freeing Memory
if (image.DisposingLibrary != null) image.DisposingLibrary.Dispose(image);
// Updating image data
image.Rescale(width, height);
libraryData.Image = scratchImage;
libraryData.DxtImages = libraryData.Image.GetImages();
libraryData.Metadata = libraryData.Image.metadata;
image.DisposingLibrary = this;
UpdateImage(image, libraryData);
}
示例3: Rescale
/// <summary>
/// Rescales the specified image.
/// </summary>
/// <param name="image">The image.</param>
/// <param name="libraryData">The library data.</param>
/// <param name="request">The request.</param>
private void Rescale(TexImage image, PvrTextureLibraryData libraryData, RescalingRequest request)
{
int width = request.ComputeWidth(image);
int height = request.ComputeHeight(image);
Log.Info("Rescaling to " + width + "x" + height + " ...");
EResizeMode filter;
switch(request.Filter)
{
case Filter.Rescaling.Bilinear:
filter = EResizeMode.eResizeLinear;
break;
case Filter.Rescaling.Bicubic:
filter = EResizeMode.eResizeCubic;
break;
case Filter.Rescaling.Nearest:
filter = EResizeMode.eResizeNearest;
break;
default:
filter = EResizeMode.eResizeCubic;
break;
}
Utilities.Resize(libraryData.Texture, (uint)width, (uint)height, (uint)image.Depth, filter);
UpdateImage(image, libraryData);
// Updating image data
image.Rescale(width, height);
}