200 lines
5.1 KiB
C#
200 lines
5.1 KiB
C#
using System.Drawing;
|
|
using ClassLibrary;
|
|
|
|
namespace Treko
|
|
{
|
|
public class Treko : Technology
|
|
{
|
|
#region Local Parameters
|
|
|
|
//private string _outDirName;
|
|
int _nFW = 20;
|
|
int _nFH = 26;
|
|
//Image _renderImage;
|
|
int[,] _pixels;
|
|
ColorPixel[,] _colorPixels;
|
|
Angles _angles;
|
|
//string _anglePath;
|
|
Image _btmBack;
|
|
string _imagePath;
|
|
int _imgDisplayTrekoWidthPix = 2000;
|
|
int _imgDisplayTrekoHeightPix = 2000;
|
|
Image _imgDisplayTreko;
|
|
string[] _lines; // Angles descriptions from ang.ini
|
|
double _radiusMax = 4.8; // Max arc;'s radius
|
|
double _step = 0.25; // Step between centers of arcs
|
|
int _arcWidth = 20; // Width of arcs (in numbers of arcs or pixels)
|
|
InfoSpace _infoSpace;
|
|
|
|
#endregion
|
|
|
|
#region Getters/Setters
|
|
|
|
public ColorPixel[,] ColorPixels
|
|
{
|
|
get { return _colorPixels; }
|
|
set { _colorPixels = value; }
|
|
}
|
|
|
|
public int ImgDisplayTrekoWidthPix
|
|
{
|
|
get { return _imgDisplayTrekoWidthPix; }
|
|
set { _imgDisplayTrekoWidthPix = value; }
|
|
}
|
|
|
|
public int ImgDisplayTrekoHeightPix
|
|
{
|
|
get { return _imgDisplayTrekoHeightPix; }
|
|
set { _imgDisplayTrekoHeightPix = value; }
|
|
}
|
|
|
|
public Image ImgDisplayTreko
|
|
{
|
|
get { return _imgDisplayTreko; }
|
|
set { _imgDisplayTreko = value; }
|
|
}
|
|
|
|
public double RadiusMax
|
|
{
|
|
get { return _radiusMax; }
|
|
set { _radiusMax = value; }
|
|
}
|
|
|
|
public double Step
|
|
{
|
|
get { return _step; }
|
|
set { _step = value; }
|
|
}
|
|
|
|
public string[] Lines
|
|
{
|
|
get { return _lines; }
|
|
set { _lines = value; }
|
|
}
|
|
|
|
public int ArcWidth
|
|
{
|
|
get { return _arcWidth; }
|
|
set { _arcWidth = value; }
|
|
}
|
|
|
|
//public int MmToPixelsCoeff
|
|
//{
|
|
// get
|
|
// {
|
|
// if (_mmToPixelsCoeff == 0)
|
|
// _mmToPixelsCoeff = Convert.ToInt32(_frameWidthPix / _frameWidth);
|
|
// return _mmToPixelsCoeff;
|
|
// }
|
|
// set { _mmToPixelsCoeff = value; }
|
|
//}
|
|
|
|
public string ImagePath
|
|
{
|
|
get { return _imagePath; }
|
|
set { _imagePath = value; }
|
|
}
|
|
|
|
public Image SourceImage
|
|
{
|
|
get { return _btmBack; }
|
|
set { _btmBack = value; }
|
|
}
|
|
|
|
public int[,] Pixels
|
|
{
|
|
get { return _pixels; }
|
|
set { _pixels = value; }
|
|
}
|
|
|
|
public InfoSpace InfoSp
|
|
{
|
|
get { return _infoSpace; }
|
|
set { _infoSpace = value; }
|
|
}
|
|
|
|
public Angles Angles
|
|
{
|
|
get { return _angles; }
|
|
set { _angles = value; }
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
public Treko()
|
|
{
|
|
|
|
}
|
|
|
|
#region Helper functions
|
|
|
|
private void fillImageByBlack(Graphics gr)
|
|
{
|
|
Color col = Color.FromArgb(0, 0, 0);
|
|
gr.Clear(col);
|
|
}
|
|
|
|
#endregion
|
|
|
|
public void GenerateAngles(string path)
|
|
{
|
|
_angles = new Angles(path);
|
|
}
|
|
|
|
public void GenVectorData(double hologramWidth, double hologramHeight)
|
|
{
|
|
//HologramWidth = 30;
|
|
//double x, y; //
|
|
|
|
_infoSpace = new InfoSpace(_radiusMax, _radiusMax, hologramWidth, hologramHeight, SourceImage.Width, SourceImage.Height, _radiusMax, _step);
|
|
|
|
_colorPixels = _infoSpace.GenVectorData(Pixels, _angles, _radiusMax);
|
|
}
|
|
|
|
public void CreateImageTreko()
|
|
{
|
|
if (_imgDisplayTreko == null)
|
|
{
|
|
_imgDisplayTreko = new Bitmap(_imgDisplayTrekoWidthPix, _imgDisplayTrekoHeightPix);
|
|
}
|
|
}
|
|
|
|
public void DrawOnImage(Image imgTreko, int _mmToPixelsCoeff)
|
|
{
|
|
//imgTreko3D.Refresh();
|
|
|
|
foreach (ColorPixel colorPix in _colorPixels)
|
|
{
|
|
if (colorPix != null)
|
|
{
|
|
//_colorPixels.MmToPixelsCoeff = MmToPixelsCoeff;
|
|
colorPix.DrawArcs(imgTreko, _mmToPixelsCoeff);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void DrawAnimation(Image imgTreko, int angPreview, int parallaxAng, int mmToPixelsCoeffPreview)
|
|
{
|
|
|
|
Graphics g = Graphics.FromImage(imgTreko); //.CreateGraphics();
|
|
Pen pen = new Pen(Color.White, 1);
|
|
Pen penRed = new Pen(Color.Red, 1);
|
|
Pen penBlue = new Pen(Color.FromArgb(0, 100, 255), 1);
|
|
|
|
foreach (ColorPixel colorPix in _colorPixels)
|
|
{
|
|
if (colorPix != null)
|
|
{
|
|
colorPix.DrawAnimation(g, pen, penRed, penBlue, angPreview, parallaxAng, mmToPixelsCoeffPreview);
|
|
}
|
|
}
|
|
|
|
pen.Dispose();
|
|
penRed.Dispose();
|
|
penBlue.Dispose();
|
|
g.Dispose();
|
|
}
|
|
}
|
|
}
|