Click here to Skip to main content
15,908,437 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
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:
C#
pixelArray[1,1] =     {{2,3}       
                       {4,5}}

this:
C#
{{2,2,3,3}
 {2,2,3,3}
 {4,4,5,5}
 {4,4,5,5} }

Is there a function in C# ?
How should I solve this problem??
Thank you!
Posted
Updated 18-Jan-12 22:55pm
v3

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:
C#
using System.Drawing.Drawing2D;

Construct a new matrix:
C#
Matrix m = new Matrix();

Scale the X by 1/2 and the y by 1 1/2:
C#
m.Scale(0.5F, 1.5F);

Apply the transformation:
C#
e.Graphics.Transform = m;
 
Share this answer
 
Comments
Radu_Socaciu 21-Jan-12 13:28pm    
My goal is to make my own jpeg coder(a simple version of it). I`ve done all my codeing for the jpeg and now I want to make a function witch when I click in a specifict point of my image to take a block of 8 by 8 pixels and display it in another picture box but zoomed 10 times.

Sorry because I couldn`t replay faster but I had some problems and I didn`t had the chance to open my pc and go online.

Thank you for your replay.
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
 
Share this answer
 
Comments
Radu_Socaciu 21-Jan-12 13:31pm    
Sorry because I couldn`t replay faster... I really apreciate your help . That link was helpfull but I have decided to copy one element at a time using a for loop.

Thhank you for your help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900