将一个数组复制到另一个数组. [英] Copy one array to another .

查看:187
本文介绍了将一个数组复制到另一个数组.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我想在btb图像上实现缩放.我有一个像素数组,我的目标是获取第一个像素,将其存储在另一个4乘4像素的数组中,然后需要对其余数组进行此操作.

所以我要做的是:

Hello

I want to implement zoom on an btb image . I have my array with pixels , my goal is to take the first pixel , store it in another array in a block of 4 by 4 pixels and then I need to do this with the rest of the array.

So what I want to do is this:

pixelArray[1,1] =     {{2,3}       
                       {4,5}}


这:

{{2,2,3,3}
 {2,2,3,3}
 {4,4,5,5}
 {4,4,5,5} }


C#中有功能吗?
我应该如何解决这个问题?
谢谢!


Is there a function in C# ?
How should I solve this problem??
Thank you!

推荐答案

.NET中没有用于执行AFAIK的功能.
编写起来并不难,但是这似乎是一种奇怪的方式:为什么通过加倍大小来缩放"图像?为什么不放大绘画例程,而只放大他们正在查看的实际位呢?您可以通过构造一个Matrix对象并应用比例因子,然后再使用它来转换图形对象来做到这一点.简单,快速,简单:
将矩阵添加到您的班级:
There is no function in .NET to do that AFAIK.
It wouldn''t be difficult to write, but it seems a strange way to do it: why are you "zooming" an image by doublingthe size? Why not do the zoom in the paint routine, where you would only enlarge the actual bit they are viewing? You can do that by constructing a Matrix object and apply a scale factor before using it to transform the graphics object. Easy, quick and simple:
Add the Matrix to your class:
using System.Drawing.Drawing2D;


构造一个新矩阵:


Construct a new matrix:

Matrix m = new Matrix();


将X按1/2缩放,将y按1 1/2缩放:


Scale the X by 1/2 and the y by 1 1/2:

m.Scale(0.5F, 1.5F);


应用转换:


Apply the transformation:

e.Graphics.Transform = m;


是的,您可以使用一个或多个静态方法System.Array.Copy
Yes, you can use one or more of the static methods System.Array.Copy, http://msdn.microsoft.com/en-us/library/system.array.aspx[^].

If by any reason you find those methods too hard to understand (yes, at least they need considerable attention), you are reduced to copying one element at a time in a loop. I hope this is clear enough.

—SA


这篇关于将一个数组复制到另一个数组.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆