diff --git "a/E:\\OpenCV2.4\\opencv\\modules\\imgproc\\src\\color-ORIG.cpp" "b/E:\\OpenCV2.4\\opencv\\modules\\imgproc\\src\\color-RGBA.cpp"
index c4e20b5..7f17b77 100644
--- "a/E:\\OpenCV2.4\\opencv\\modules\\imgproc\\src\\color-ORIG.cpp"
+++ "b/E:\\OpenCV2.4\\opencv\\modules\\imgproc\\src\\color-RGBA.cpp"
@@ -1879,6 +1879,94 @@ public:
         return (int)(bayer - (bayer_end - width));
     }
     
+	// MGB RGBA support
+	// THIS doesn't 'quite' work - need some help!
+	 int bayer2RGBA(const uchar* bayer, int bayer_step, uchar* dst, int width, int blue) const
+    {
+		
+        if( !use_simd )
+            return 0;
+        /*
+         B G B G | B G B G | B G B G | B G B G
+         G R G R | G R G R | G R G R | G R G R
+         B G B G | B G B G | B G B G | B G B G
+         */
+        __m128i delta1 = _mm_set1_epi16(1), delta2 = _mm_set1_epi16(2);
+        __m128i mask = _mm_set1_epi16(blue < 0 ? -1 : 0);
+		//__m128i z = _mm_setzero_si128();        						
+		__m128i z = _mm_set_epi32(0xffffffff,0xffffffff,0xffffffff,0xffffffff);
+
+		__m128i masklo = _mm_set1_epi16(0x00ff);
+        const uchar* bayer_end = bayer + width;
+                 
+		for( ; bayer <= bayer_end - 18; bayer += 14, dst += 56 )
+        {
+            __m128i r0 = _mm_loadu_si128((const __m128i*)bayer);
+            __m128i r1 = _mm_loadu_si128((const __m128i*)(bayer+bayer_step));
+            __m128i r2 = _mm_loadu_si128((const __m128i*)(bayer+bayer_step*2));
+            
+            __m128i b1 = _mm_add_epi16(_mm_and_si128(r0, masklo), _mm_and_si128(r2, masklo));
+            __m128i b0 = _mm_add_epi16(b1, _mm_srli_si128(b1, 2));
+            b1 = _mm_srli_si128(b1, 2);
+            b1 = _mm_srli_epi16(_mm_add_epi16(b1, delta1), 1);
+            b0 = _mm_srli_epi16(_mm_add_epi16(b0, delta2), 2);
+            b0 = _mm_packus_epi16(b0, b1);
+            
+            __m128i g0 = _mm_add_epi16(_mm_srli_epi16(r0, 8), _mm_srli_epi16(r2, 8));
+            __m128i g1 = _mm_and_si128(r1, masklo);
+            g0 = _mm_add_epi16(g0, _mm_add_epi16(g1, _mm_srli_si128(g1, 2)));
+            g1 = _mm_srli_si128(g1, 2);
+            g0 = _mm_srli_epi16(_mm_add_epi16(g0, delta2), 2);
+            g0 = _mm_packus_epi16(g0, g1);
+            
+            r0 = _mm_srli_epi16(r1, 8);
+            r1 = _mm_add_epi16(r0, _mm_srli_si128(r0, 2));
+            r1 = _mm_srli_epi16(_mm_add_epi16(r1, delta1), 1);
+            r0 = _mm_packus_epi16(r0, r1);
+            
+            b1 = _mm_and_si128(_mm_xor_si128(b0, r0), mask);
+            b0 = _mm_xor_si128(b0, b1);
+            r0 = _mm_xor_si128(r0, b1);
+            
+            // b1 g1 b1 g1 ...
+            b1 = _mm_unpackhi_epi8(b0, g0);
+            // b0 g0 b2 g2 b4 g4 ....
+            b0 = _mm_unpacklo_epi8(b0, g0);
+            
+            // r1 0 r3 0 ...
+            r1 = _mm_unpackhi_epi8(r0, z);
+            // r0 0 r2 0 r4 0 ...
+            r0 = _mm_unpacklo_epi8(r0, z);
+            
+            // 0 b0 g0 r0 0 b2 g2 r2 0 ...
+            g0 = _mm_slli_si128(_mm_unpacklo_epi16(b0, r0), 1);
+            // 0 b8 g8 r8 0 b10 g10 r10 0 ...
+            g1 = _mm_slli_si128(_mm_unpackhi_epi16(b0, r0), 1);
+            
+            // b1 g1 r1 0 b3 g3 r3 ....
+            r0 = _mm_unpacklo_epi16(b1, r1);
+            // b9 g9 r9 0 ...
+            r1 = _mm_unpackhi_epi16(b1, r1);
+            
+            b0 = _mm_srli_si128(_mm_unpacklo_epi32(g0, r0), 1);
+            b1 = _mm_srli_si128(_mm_unpackhi_epi32(g0, r0), 1);
+            
+            _mm_storel_epi64((__m128i*)(dst-0), b0);
+            _mm_storel_epi64((__m128i*)(dst-0+8*1), _mm_srli_si128(b0, 8));
+            _mm_storel_epi64((__m128i*)(dst-0+8*2), b1);
+            _mm_storel_epi64((__m128i*)(dst-0+8*3), _mm_srli_si128(b1, 8));
+
+            g0 = _mm_srli_si128(_mm_unpacklo_epi32(g1, r1), 1);
+            g1 = _mm_srli_si128(_mm_unpackhi_epi32(g1, r1), 1);
+            
+            _mm_storel_epi64((__m128i*)(dst-0+8*4), g0);
+            _mm_storel_epi64((__m128i*)(dst-0+8*5), _mm_srli_si128(g0, 8));            
+            _mm_storel_epi64((__m128i*)(dst-0+8*6), g1);
+
+        }
+        // end MGB RGBA support
+        return (int)(bayer - (bayer_end - width));
+    }
     bool use_simd;
 };
 #else
@@ -2110,7 +2198,148 @@ static void Bayer2RGB_( const Mat& srcmat, Mat& dstmat, int code )
         }
 }
 
+// MGB RGBA support
+template<typename T, class SIMDInterpolator>    
+static void Bayer2RGBA_( const Mat& srcmat, Mat& dstmat, int code )
+{
+    SIMDInterpolator vecOp;
+	
+    const T* bayer0 = (const T*)srcmat.data;
+    int bayer_step = (int)(srcmat.step/sizeof(T));
+    T* dst0 = (T*)dstmat.data;
+    int dst_step = (int)(dstmat.step/sizeof(T));
+    Size size = srcmat.size();
+    int blue = code == CV_BayerBG2BGRA || code == CV_BayerGB2BGRA ? -1 : 1;
+    int start_with_green = code == CV_BayerGB2BGRA || code == CV_BayerGR2BGRA;
     
+	T alpha = 0xff;
+
+    dst0 += dst_step + 4 + 1;
+    size.height -= 2;
+    size.width -= 2;
+        
+    for( ; size.height-- > 0; bayer0 += bayer_step, dst0 += dst_step )
+    {
+        int t0, t1;
+        const T* bayer = bayer0;
+        T* dst = dst0;
+        const T* bayer_end = bayer + size.width;
+        
+        if( size.width <= 0 )
+        {
+            dst[-4] = dst[-3] = dst[-2] = dst[size.width*4-1] =
+            dst[size.width*4] = dst[size.width*4+1] = 0;
+            continue;
+        }
+        
+        if( start_with_green )
+        {
+            t0 = (bayer[1] + bayer[bayer_step*2+1] + 1) >> 1;
+            t1 = (bayer[bayer_step] + bayer[bayer_step+2] + 1) >> 1;
+            dst[-blue] = (T)t0;
+            dst[0] = bayer[bayer_step+1];
+            dst[blue] = (T)t1;
+            bayer++;
+            dst += 4;
+        }
+        
+		// Can't make the SIMD work quite correctly
+        //int delta = vecOp.bayer2RGBA(bayer, bayer_step, dst, size.width, blue);
+		int delta = 0;
+        bayer += delta;
+        dst += delta*4;
+                
+        if( blue > 0 )
+        {
+            for( ; bayer <= bayer_end - 2; bayer += 2, dst += 8 )
+            {
+                t0 = (bayer[0] + bayer[2] + bayer[bayer_step*2] +
+                      bayer[bayer_step*2+2] + 2) >> 2;
+                t1 = (bayer[1] + bayer[bayer_step] +
+                      bayer[bayer_step+2] + bayer[bayer_step*2+1]+2) >> 2;
+                dst[-1] = (T)t0;
+                dst[0] = (T)t1;
+                dst[1] = bayer[bayer_step+1];
+                				
+				dst[2] = alpha;
+
+                t0 = (bayer[2] + bayer[bayer_step*2+2] + 1) >> 1;
+                t1 = (bayer[bayer_step+1] + bayer[bayer_step+3] + 1) >> 1;
+                dst[3] = (T)t0;
+                dst[4] = bayer[bayer_step+2];
+                dst[5] = (T)t1;
+				
+				dst[6] = alpha;
+            }
+        }
+        else
+        {
+            for( ; bayer <= bayer_end - 2; bayer += 2, dst += 8 )
+            {
+                t0 = (bayer[0] + bayer[2] + bayer[bayer_step*2] +
+                      bayer[bayer_step*2+2] + 2) >> 2;
+                t1 = (bayer[1] + bayer[bayer_step] +
+                      bayer[bayer_step+2] + bayer[bayer_step*2+1]+2) >> 2;
+				
+				dst[2] = alpha;
+                
+				dst[1] = (T)t0;
+                dst[0] = (T)t1;
+                dst[-1] = bayer[bayer_step+1];
+                
+
+                t0 = (bayer[2] + bayer[bayer_step*2+2] + 1) >> 1;
+                t1 = (bayer[bayer_step+1] + bayer[bayer_step+3] + 1) >> 1;				
+				dst[6] = alpha; 
+
+                dst[5] = (T)t0;
+                dst[4] = bayer[bayer_step+2];
+                dst[3] = (T)t1;
+            }
+        }
+        
+        if( bayer < bayer_end )
+        {
+            t0 = (bayer[0] + bayer[2] + bayer[bayer_step*2] +
+                  bayer[bayer_step*2+2] + 2) >> 2;
+            t1 = (bayer[1] + bayer[bayer_step] +
+                  bayer[bayer_step+2] + bayer[bayer_step*2+1]+2) >> 2;
+            dst[-blue] = (T)t0;
+            dst[0] = (T)t1;
+            dst[blue] = bayer[bayer_step+1];
+            bayer++;
+            dst += 4;
+        }
+        
+		
+        dst0[-4] = dst0[-1];
+        dst0[-3] = dst0[0];
+        dst0[-2] = dst0[1];
+        dst0[size.width*4-1] = dst0[size.width*4-4];
+        dst0[size.width*4] = dst0[size.width*4-3];
+        dst0[size.width*4+1] = dst0[size.width*4-2];
+        
+        blue = -blue;
+        start_with_green = !start_with_green;
+    }
+    
+	
+    size = dstmat.size();
+    dst0 = (T*)dstmat.data;
+    if( size.height > 2 )
+        for( int i = 0; i < size.width*4; i++ )
+        {
+            dst0[i] = dst0[i + dst_step];
+            dst0[i + (size.height-1)*dst_step] = dst0[i + (size.height-2)*dst_step];
+        }
+    else
+        for( int i = 0; i < size.width*4; i++ )
+        {
+            dst0[i] = dst0[i + (size.height-1)*dst_step] = 0;
+        }
+	
+}
+// end MGB    
 /////////////////// Demosaicing using Variable Number of Gradients ///////////////////////
     
 static void Bayer2RGB_VNG_8u( const Mat& srcmat, Mat& dstmat, int code )
@@ -3474,12 +3703,31 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
             else
                 CV_Error(CV_StsUnsupportedFormat, "Bayer->Gray demosaicing only supports 8u and 16u types");
             break;
-            
-        case CV_BayerBG2BGR: case CV_BayerGB2BGR: case CV_BayerRG2BGR: case CV_BayerGR2BGR:
+
+		// MGB RGBA support  		
+		case CV_BayerBG2BGRA: case CV_BayerGB2BGRA: case CV_BayerRG2BGRA: case CV_BayerGR2BGRA:
+            if(dcn <= 0) dcn = 4;   
+			CV_Assert( scn == 1 && dcn == 4 );
+
+			_dst.create(sz, CV_MAKETYPE(depth, dcn));
+            dst = _dst.getMat();
+
+			if  ( code == CV_BayerBG2BGRA || code == CV_BayerGB2BGRA ||
+						code == CV_BayerRG2BGRA || code == CV_BayerGR2BGRA )
+			{
+				
+				if( depth == CV_8U )
+				        Bayer2RGBA_<uchar, SIMDBayerInterpolator_8u>(src, dst, code);                                
+                else
+                    CV_Error(CV_StsUnsupportedFormat, "Bayer->RGBA demosaicing only supports 8u types");
+			}
+			break;
+
+        case CV_BayerBG2BGR: case CV_BayerGB2BGR: case CV_BayerRG2BGR: case CV_BayerGR2BGR:	    
         case CV_BayerBG2BGR_VNG: case CV_BayerGB2BGR_VNG: case CV_BayerRG2BGR_VNG: case CV_BayerGR2BGR_VNG:
             if(dcn <= 0) dcn = 3;
             CV_Assert( scn == 1 && dcn == 3 );
-            
+
             _dst.create(sz, CV_MAKETYPE(depth, dcn));
             dst = _dst.getMat();
             
@@ -3492,8 +3740,8 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
                     Bayer2RGB_<ushort, SIMDBayerStubInterpolator_<ushort> >(src, dst, code);
                 else
                     CV_Error(CV_StsUnsupportedFormat, "Bayer->RGB demosaicing only supports 8u and 16u types");
-            }
-            else
+			}
+			else
             {
                 CV_Assert( depth == CV_8U );
                 Bayer2RGB_VNG_8u(src, dst, code);
