Click here to Skip to main content
15,893,594 members
Articles / Desktop Programming / MFC

Fast SIMD Prototyping

Rate me:
Please Sign up or sign in to vote.
4.97/5 (51 votes)
30 Oct 2016Ms-PL9 min read 74.8K   1.4K   99  
Prototype SIMD vectorized code effortlessly.
// HexCoverDlg.h : header file
//

#pragma once
#include <dvec.h>
#include <fvec.h>
#include <vector>

struct HexCenter
{
	int x;
	int y;
	int dist;
};

// CHexCoverDlg dialog
class CHexCoverDlg : public CDialogEx
{
// Construction
public:
	CHexCoverDlg(CWnd* pParent = NULL);	// standard constructor
	~CHexCoverDlg();	// standard constructor
private:

	void LoadSrcImage1();
	void LoadSrcImage2();
	void LoadSmallDistImage();
	void LoadSmallRedMaskImage();

	float ComputeDistance(float fPointX1, float fPointY1, float fPointX2, float fPointY2);

	float MaxDistance(float a, float b, float c, float d);

	void Draw();

	void GenDistanceMask();

	void GenArrayIndexMask();

	void SetValueToImage(Gdiplus::Bitmap* smallRedMask, Gdiplus::Bitmap* destImage, UINT val);

	void ComputeCenterDist();

	Gdiplus::Bitmap* m_pSrcBitmap1;

	Gdiplus::Bitmap* m_pSrcBitmap2;

	Gdiplus::Bitmap* m_pCanvas;

	Gdiplus::Bitmap* m_pDistanceMask;

	Gdiplus::Bitmap* m_pRedMask;

	Gdiplus::Bitmap* m_pSmallDistanceMask;

	Gdiplus::Bitmap* m_pSmallRedMask;

	int m_numPixels;

	int m_totalLength;

	bool m_firstImage;

	float m_fPointX;

	float m_fPointY;

	UINT  m_wTimerRes;

	int m_nSpeed;
	
	float m_fSpeed;

	std::vector<HexCenter> m_vecHexCenter;

public:

// Dialog Data
	enum { IDD = IDD_HEXCOVER_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnDestroy();
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Software Developer (Senior)
Singapore Singapore
Shao Voon is from Singapore. His interest lies primarily in computer graphics, software optimization, concurrency, security, and Agile methodologies.

In recent years, he shifted focus to software safety research. His hobby is writing a free C++ DirectX photo slideshow application which can be viewed here.

Comments and Discussions