imageeditorengine/filters/FilterDraw/Src/cfilterdraw.cpp
author qifeima <>
Thu, 03 Jun 2010 18:57:10 +0800
changeset 8 18b321db4884
parent 1 edfc90759b9f
permissions -rw-r--r--
*m enhance
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
     1
/*
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
     2
 * Copyright (c) 2010 Ixonos Plc.
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
     3
 * All rights reserved.
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
     4
 * This component and the accompanying materials are made available
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
     5
 * under the terms of the "Eclipse Public License v1.0"
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
     6
 * which accompanies this distribution, and is available
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
     8
 *
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
     9
 * Initial Contributors:
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    10
 * Nokia Corporation - Initial contribution
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    11
 *
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    12
 * Contributors:
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    13
 * Ixonos Plc
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    14
 *
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    15
 * Description:  
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    16
 * Draw filter for Draw UI plugin.
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    17
 *
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    18
 */
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    19
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    20
#include <fbs.h>
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    21
#include <bitdev.h>
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    22
#include <e32math.h>
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    23
#include "cfilterdraw.h"
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    24
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    25
const TInt KDrawBitmapWidth(480);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    26
const TInt KDrawBitmapHeight(640);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    27
TUint32* CFilterDraw::iData = NULL;
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    28
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    29
// Create
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    30
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    31
//
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    32
EXPORT_C TInt CFilterDraw::Create()
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    33
	{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    34
	CFilterDraw* ptr = NULL;
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    35
	TRAP_IGNORE( ptr = NewL() );
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    36
	return (TInt) ((MImageFilter*) ptr);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    37
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    38
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    39
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    40
// NewL
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    41
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    42
//
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    43
CFilterDraw* CFilterDraw::NewL()
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    44
	{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    45
	return new (ELeave) CFilterDraw();
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    46
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    47
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    48
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    49
// ~CFilterDraw
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    50
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    51
//
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    52
CFilterDraw::~CFilterDraw()
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    53
	{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    54
	if(iData)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    55
	{
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    56
	delete[] iData;
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    57
	iData = NULL;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    58
	}
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    59
	iReadyToRender = EFalse;
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    60
	// Close all paths
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    61
	for (TInt i(0); i < iPaths.Count(); i++)
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    62
		{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    63
		iPaths[i].Close();
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    64
		}
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    65
	iPaths.Close();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    66
	
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    67
	for (TInt j(0); j < iUndoPaths.Count(); j++)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    68
		{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    69
		iUndoPaths[j].Close();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    70
		}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    71
	iUndoPaths.Close();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    72
	
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    73
	if(iMask)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    74
		{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    75
		delete iMask;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    76
		iMask =NULL;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    77
		}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    78
	if(iBitmap)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    79
		{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    80
		delete iBitmap;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    81
		iBitmap =NULL;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    82
		}
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    83
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    84
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    85
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    86
// CFilterDraw
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    87
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    88
//
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    89
CFilterDraw::CFilterDraw() :
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    90
	 iBitmapSize(KDrawBitmapWidth, KDrawBitmapHeight), iCanRedo(
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
    91
			EFalse)
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    92
	{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    93
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    94
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    95
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    96
// Rect
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    97
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    98
//
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
    99
TRect CFilterDraw::Rect()
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   100
	{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   101
	ASSERT(iChild);
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   102
	return iChild->Rect();
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   103
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   104
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   105
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   106
// Scale
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   107
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   108
//
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   109
TReal CFilterDraw::Scale()
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   110
	{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   111
	ASSERT(iChild);
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   112
	return iChild->Scale();
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   113
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   114
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   115
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   116
// ViewPortSize
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   117
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   118
//
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   119
TSize CFilterDraw::ViewPortSize()
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   120
	{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   121
	ASSERT(iChild);
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   122
	return iChild->ViewPortSize();
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   123
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   124
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   125
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   126
// GetBlockL
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   127
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   128
//
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   129
TBlock* CFilterDraw::GetBlockL(const TRect& aRect)
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   130
	{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   131
	ASSERT(iChild);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   132
	TBlock* pB = iChild->GetBlockL(aRect);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   133
	if (!pB)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   134
		return NULL;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   135
	TUint32* pD = pB->iData;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   136
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   137
	if (iData && iReadyToRender)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   138
		{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   139
		// Factor between real and viewed image
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   140
		TReal realToViewedFactorWidth;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   141
		TReal realToViewedFactorHeight;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   142
		RealToViewedFactories(realToViewedFactorWidth, realToViewedFactorHeight);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   143
		const TInt width(iBitmapSize.iWidth); // Data bitmap width
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   144
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   145
		for (TInt y(pB->iRect.iTl.iY); y < pB->iRect.iBr.iY; ++y)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   146
			{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   147
			TInt realY(y / Scale() + 0.5);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   148
			TInt viewY(realY / realToViewedFactorHeight + 0.5);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   149
			for (TInt x(pB->iRect.iTl.iX); x < pB->iRect.iBr.iX; ++x)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   150
				{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   151
				TInt realX(x / Scale() + 0.5);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   152
				TInt viewX(realX / realToViewedFactorWidth + 0.5);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   153
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   154
				if( viewY >= KDrawBitmapHeight)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   155
					{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   156
					viewY--;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   157
					}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   158
				if(iData[width * viewY + viewX])
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   159
					{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   160
					TUint32 color = iData[width * viewY + viewX];
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   161
					if ((color & 0xff000000))
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   162
						{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   163
						*pD = color;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   164
						}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   165
					}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   166
				*pD++;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   167
				}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   168
			}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   169
		}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   170
	
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   171
	return pB;
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   172
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   173
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   174
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   175
// SetParent
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   176
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   177
//
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   178
void CFilterDraw::SetParent(MImageFilter* aParent)
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   179
	{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   180
	ASSERT(aParent);
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   181
	iParent = aParent;
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   182
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   183
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   184
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   185
// SetChild
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   186
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   187
//
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   188
void CFilterDraw::SetChild(MImageFilter* aChild)
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   189
	{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   190
	ASSERT(aChild);
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   191
	iChild = aChild;
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   192
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   193
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   194
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   195
// CmdL
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   196
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   197
//
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   198
TInt CFilterDraw::CmdL(const TDesC16& aCmd)
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   199
	{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   200
	TInt bbb(0);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   201
	bbb = iPaths.Count();
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   202
	ASSERT(iChild);
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   203
	TLex lex(aCmd);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   204
	TPoint position(0, 0);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   205
	// Factor between real and viewed image
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   206
	TReal realToViewedFactorWidth;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   207
	TReal realToViewedFactorHeight;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   208
	RealToViewedFactories(realToViewedFactorWidth, realToViewedFactorHeight);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   209
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   210
	//	Handle parameters
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   211
	while (!lex.Eos())
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   212
		{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   213
		RDebug::RawPrint(aCmd);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   214
		TPtrC token = lex.NextToken();
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   215
		TInt pathCount(0);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   216
		pathCount = iPaths.Count();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   217
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   218
		if (token.Compare(_L("x")) == 0)
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   219
			{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   220
			iCanRedo = EFalse;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   221
			for (TInt j(0); j < iUndoPaths.Count(); j++)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   222
				{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   223
				iUndoPaths[j].Close();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   224
				}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   225
			iUndoPaths.Close();
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   226
			iReadyToRender = EFalse;
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   227
			TReal relscale = Scale();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   228
			TInt param = 0;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   229
			lex.Inc();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   230
			lex.Val(param);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   231
			// Coordinates on data bitmap
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   232
			position.iX = (TReal(param) / relscale) / realToViewedFactorWidth + 0.5;
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   233
			}
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   234
		else if (token.Compare(_L("y")) == 0)
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   235
			{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   236
			TReal relscale = Scale();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   237
			TInt param = 0;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   238
			lex.Inc();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   239
			lex.Val(param);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   240
			position.iY = (TReal(param) / relscale) / realToViewedFactorHeight + 0.5;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   241
			RDebug::Print(
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   242
					_L("CFilterDraw::CmdL x:%d y:%d Scale:%g Rw:%d Rh:%d Vpw:%d Vph:%d Rtvw:%g Rtvh:%g"),
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   243
					position.iX, position.iY, relscale, Rect().Size().iWidth,
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   244
					Rect().Size().iHeight, ViewPortSize().iWidth,
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   245
					ViewPortSize().iHeight, realToViewedFactorWidth,
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   246
					realToViewedFactorHeight);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   247
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   248
			if (!iPaths.Count())
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   249
				{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   250
				RDrawPath newPath;
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   251
				User::LeaveIfError(newPath.Append(position));
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   252
				User::LeaveIfError(iPaths.Append(newPath));
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   253
				}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   254
			else
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   255
				{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   256
				ASSERT(iPaths.Count());
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   257
				RDrawPath& lastPath = iPaths[iPaths.Count() - 1];
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   258
				User::LeaveIfError(lastPath.Append(position));
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   259
				}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   260
			}
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   261
		else if (token.Compare(_L("color")) == 0)
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   262
			{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   263
			TUint32 color(0);
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   264
			lex.Inc();
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   265
			lex.Val(color, EDecimal);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   266
			TRgb rgb(color);
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   267
			TUint32 colorValue = (rgb.Red() << 16) + (rgb.Green() << 8)	+ rgb.Blue();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   268
			ASSERT( iPaths.Count() );
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   269
			RDrawPath& lastPath = iPaths[iPaths.Count() - 1];
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   270
			lastPath.SetColor(TRgb(colorValue));
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   271
			}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   272
		else if (token.Compare(_L("size")) == 0)
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   273
			{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   274
			TInt size(0);
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   275
			lex.Inc();
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   276
			lex.Val(size);
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   277
			// Scale line size to match bitmap scale
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   278
			TInt sizew( (TReal(size) / realToViewedFactorWidth) + 0.5 );
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   279
			TInt sizeh( (TReal(size) / realToViewedFactorHeight) + 0.5 );
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   280
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   281
			if (!sizew)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   282
				{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   283
				sizew++;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   284
				}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   285
			if (!sizeh)
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   286
				{
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   287
				sizeh++;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   288
				}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   289
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   290
			if (iPaths.Count())
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   291
				{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   292
				RDrawPath& lastPath = iPaths[iPaths.Count() - 1];
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   293
				lastPath.SetSize(TSize(sizew, sizeh));
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   294
				}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   295
			}
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   296
		else if (token.Compare(_L("lastItem")) == 0)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   297
			{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   298
			ASSERT(iPaths.Count());
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   299
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   300
			RDrawPath& lastPath = iPaths[iPaths.Count() - 1];
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   301
			RDebug::Print(
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   302
					_L("CFilterDraw::CmdL lastItem count:%d size:%d r:%d g:%d b:%d"),
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   303
					iPaths.Count(), lastPath.Size().iHeight,
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   304
					lastPath.Color().Red(), lastPath.Color().Green(),
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   305
					lastPath.Color().Blue());
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   306
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   307
			RDrawPath newPath;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   308
			User::LeaveIfError(iPaths.Append(newPath));
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   309
			}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   310
		else if (token.Compare(_L("done")) == 0)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   311
			{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   312
			LoadFrameL();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   313
			iReadyToRender = ETrue;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   314
			}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   315
		//Undo functionality
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   316
		else if (token.Compare(_L("Undo")) == 0)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   317
			{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   318
			TInt count(0);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   319
			count = iPaths.Count();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   320
			count = iUndoPaths.Count();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   321
			
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   322
			if (iPaths.Count() > 1)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   323
				{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   324
				TInt count = iPaths.Count();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   325
				iUndoPaths.Append(iPaths[iPaths.Count() - 2]);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   326
				iPaths.Remove(iPaths.Count() - 2);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   327
				iCanRedo = ETrue;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   328
				}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   329
			count = iPaths.Count();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   330
			count = iUndoPaths.Count();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   331
			}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   332
		//Redo functionality
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   333
		else if (token.Compare(_L("redone")) == 0)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   334
			{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   335
			TInt count(0);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   336
			count = iPaths.Count();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   337
			count = iUndoPaths.Count();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   338
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   339
			if (iCanRedo)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   340
				{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   341
				if (iUndoPaths.Count())
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   342
					{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   343
					if (iPaths.Count() >= 1)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   344
						{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   345
						iPaths.Insert(iUndoPaths[iUndoPaths.Count() - 1],iPaths.Count() - 1);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   346
						iUndoPaths.Remove(iUndoPaths.Count() - 1);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   347
						}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   348
					}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   349
				}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   350
			count = iPaths.Count();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   351
			count = iUndoPaths.Count();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   352
			}
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   353
		}
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   354
	return KErrNone;
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   355
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   356
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   357
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   358
// Type
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   359
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   360
//
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   361
const char* CFilterDraw::Type()
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   362
	{
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   363
	return "frame";
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   364
	}
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   365
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   366
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   367
// LoadFrameL
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   368
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   369
//
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   370
void CFilterDraw::LoadFrameL()
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   371
	{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   372
	RDebug::Print(_L("CFilterDraw::LoadFrameL w:%d h:%d"), iBitmapSize.iWidth,
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   373
			iBitmapSize.iHeight);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   374
	
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   375
	TInt xxx(0);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   376
	xxx = iPaths.Count();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   377
	//  Create a bitmap big enough to hold the drawed lines
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   378
	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   379
	CleanupStack::PushL(bitmap);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   380
	User::LeaveIfError(bitmap->Create(iBitmapSize, EColor16MA));
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   381
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   382
	// create mask
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   383
	CFbsBitmap* mask = new (ELeave) CFbsBitmap();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   384
	CleanupStack::PushL(mask);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   385
	User::LeaveIfError(mask->Create(iBitmapSize, EColor16MA));
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   386
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   387
	CFbsBitmapDevice* maskDevice = CFbsBitmapDevice::NewL(mask);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   388
	CleanupStack::PushL(maskDevice);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   389
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   390
	CFbsBitGc * maskContext(NULL);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   391
	User::LeaveIfError(maskDevice->CreateContext(maskContext));
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   392
	CleanupStack::PushL(maskContext);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   393
	maskContext->SetPenStyle(CGraphicsContext::ESolidPen);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   394
	maskContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   395
	maskContext->SetBrushColor(KRgbBlack);
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   396
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   397
	//  Create bitmap device and context
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   398
	CFbsBitmapDevice * bitmapDevice = CFbsBitmapDevice::NewL(bitmap);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   399
	CleanupStack::PushL(bitmapDevice);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   400
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   401
	//	Create bitmap graphics context
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   402
	CFbsBitGc * bitmapContext(NULL);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   403
	User::LeaveIfError(bitmapDevice->CreateContext(bitmapContext));
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   404
	CleanupStack::PushL(bitmapContext);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   405
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   406
	TDisplayMode dmode = bitmap->DisplayMode();
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   407
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   408
	for (TInt pathNumber(0); pathNumber < iPaths.Count(); pathNumber++)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   409
		{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   410
		RDrawPath path = iPaths[pathNumber];
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   411
		bitmapContext->SetPenStyle(CGraphicsContext::ESolidPen);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   412
		bitmapContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   413
		bitmapContext->SetPenColor(path.Color());
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   414
		bitmapContext->SetPenSize(path.Size());
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   415
		maskContext->SetPenSize(path.Size());
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   416
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   417
		RDebug::Print(_L("CFilterDraw::LoadFrameL ps:%dx%d S:%g"),
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   418
				path.Size().iWidth, path.Size().iHeight, Scale());
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   419
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   420
		CArrayFix<TPoint>* pointArray = NULL;
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   421
		RDrawPath2PointArray(path, pointArray);
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   422
		bitmapContext->DrawPolyLine(pointArray);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   423
		maskContext->DrawPolyLine(pointArray);
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   424
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   425
		delete pointArray;
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   426
		}
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   427
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   428
	//	Create memory buffer to hold rendered image data
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   429
    
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   430
	if (!iData)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   431
		{		
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   432
		iData = new (ELeave) TUint32[iBitmapSize.iWidth * iBitmapSize.iHeight];
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   433
		Mem::FillZ(iData, iBitmapSize.iWidth * iBitmapSize.iHeight
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   434
								* sizeof(TUint32));
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   435
		}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   436
	
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   437
	TBitmapUtil bm(bitmap);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   438
	bm.Begin(TPoint(0, 0));
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   439
	TBitmapUtil maskbm(mask);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   440
	maskbm.Begin(TPoint(0, 0));
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   441
	TRgb rgb(0);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   442
	
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   443
	// Find drawed lines from bitmap    
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   444
	for (TInt y(0); y < iBitmapSize.iHeight - 1; y++)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   445
		{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   446
		for (TInt x(0); x < iBitmapSize.iWidth - 1; x++)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   447
			{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   448
			// Check mask first
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   449
			maskbm.SetPos(TPoint(x, y));
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   450
			if (maskbm.GetPixel() == KRgbBlack.Internal())
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   451
				{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   452
				bm.SetPos(TPoint(x, y));
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   453
				rgb = bm.GetPixel();
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   454
				iData[(iBitmapSize.iWidth * y) + x] = (rgb.Red() << 16)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   455
						+ (rgb.Green() << 8) + rgb.Blue() | 0xff000000;
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   456
				}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   457
			}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   458
		}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   459
	
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   460
	bm.End();
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   461
	maskbm.End();
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   462
	// bitmapContext, bitmapDevice, maskContext, maskDevice, mask, bitmap
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   463
	CleanupStack::PopAndDestroy(6, bitmap);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   464
	RDebug::Print(_L("CFilterDraw::LoadFrameL - end"));
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   465
	}
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   466
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   467
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   468
// RDrawPath2PointArray
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   469
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   470
//
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   471
void CFilterDraw::RDrawPath2PointArray(const RDrawPath& aPath,
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   472
		CArrayFix<TPoint>*& aArrayPtr) const
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   473
	{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   474
	// if allocation fails just do nothing. +1 if count is zero
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   475
	aArrayPtr = new CArrayFixFlat<TPoint> (aPath.Count() + 1);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   476
	if (aArrayPtr)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   477
		{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   478
		for (TInt i(0); i < aPath.Count(); i++)
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   479
			{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   480
			TPoint item = aPath[i];
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   481
			TRAP_IGNORE( aArrayPtr->AppendL( item ) );
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   482
			}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   483
		}
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   484
	}
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   485
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   486
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   487
// RealToViewedFactories
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   488
// ---------------------------------------------------------------------------
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   489
//
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   490
void CFilterDraw::RealToViewedFactories(TReal& aWidth, TReal& aHeight)
8
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   491
	{
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   492
	// Factor between real and viewed image
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   493
	aWidth = TReal(ViewPortSize().iWidth) / TReal(iBitmapSize.iWidth);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   494
	aHeight = TReal(ViewPortSize().iHeight) / TReal(iBitmapSize.iHeight);
18b321db4884 *m enhance
qifeima <>
parents: 1
diff changeset
   495
	}
1
edfc90759b9f Committing the Image Editor package under the Eclipse Public License
Mikael Laine <mikael.laine@ixonos.com>
parents:
diff changeset
   496