Exemplo n.º 1
0
 internal static EosFocusPoint Create(Edsdk.EdsFocusPoint focusPoint)
 {
     return new EosFocusPoint
     {
         Bounds = new Rectangle {
             X = focusPoint.rect.x,
             Y = focusPoint.rect.y,
             Height = focusPoint.rect.height,
             Width = focusPoint.rect.width,
         },
         IsInFocus = focusPoint.justFocus != 0,
         IsSelected = focusPoint.selected != 0,
         IsValid = focusPoint.valid != 0,
     };
 }
Exemplo n.º 2
0
 internal static EosFocus Create(Edsdk.EdsFocusInfo focus)
 {
     var focusPoints = new EosFocusPoint[focus.pointNumber];
     for (var i = 0; i < focusPoints.Length; ++i)
         focusPoints[i] = EosFocusPoint.Create(focus.focusPoint[i]);
     
     return new EosFocus
     {
         Bounds = new Rectangle {
             X = focus.imageRect.x,
             Y = focus.imageRect.y,
             Height = focus.imageRect.height,
             Width = focus.imageRect.width,
         },                
         ExecuteMode = focus.executeMode,                
         FocusPoints = focusPoints
     };
 }
Exemplo n.º 3
0
        private byte[] GetImage(IntPtr img_stream, Edsdk.EdsImageSource imageSource)
        {
            IntPtr stream = IntPtr.Zero;
            IntPtr img_ref = IntPtr.Zero;
            IntPtr streamPointer = IntPtr.Zero;
            Edsdk.EdsImageInfo imageInfo;
            Edsdk.EdsSize outputSize = new Edsdk.EdsSize();
            Byte[] buffer;
            Byte temp;

            //create reference to image
            Edsdk.EdsCreateImageRef(img_stream, out img_ref);
            //get information about image
            Edsdk.EdsGetImageInfo(img_ref, imageSource, out imageInfo);

            //calculate size, stride and buffersize
            outputSize.width = imageInfo.EffectiveRect.width;
            outputSize.height = imageInfo.EffectiveRect.height;
            int Stride = ((outputSize.width*3) + 3) & ~3;
            uint bufferSize = (uint) (outputSize.height*Stride);

            //Init buffer
            buffer = new Byte[bufferSize];
            //Create memory stream to buffer
            Edsdk.EdsCreateMemoryStreamFromPointer(buffer, bufferSize, out stream);
            //copy image into buffer
            Edsdk.EdsGetImage(img_ref, imageSource, Edsdk.EdsTargetImageType.RGB, imageInfo.EffectiveRect, outputSize,
                              stream);

            //makes RGB out of BGR
            if (outputSize.width%4 == 0)
            {
                for (int t = 0; t < bufferSize; t += 3)
                {
                    temp = buffer[t];
                    buffer[t] = buffer[t + 2];
                    buffer[t + 2] = temp;
                }
            }
            else
            {
                int Padding = Stride - (outputSize.width*3);
                for (int y = outputSize.height - 1; y > -1; y--)
                {
                    int RowStart = (outputSize.width*3)*y;
                    int TargetStart = Stride*y;

                    Array.Copy(buffer, RowStart, buffer, TargetStart, outputSize.width*3);

                    for (int t = TargetStart; t < TargetStart + (outputSize.width*3); t += 3)
                    {
                        temp = buffer[t];
                        buffer[t] = buffer[t + 2];
                        buffer[t + 2] = temp;
                    }
                }
            }

            //create pointer to image data
            Edsdk.EdsGetPointer(stream, out streamPointer);
            //Release all ressources
            Edsdk.EdsRelease(img_stream);
            Edsdk.EdsRelease(img_ref);
            Edsdk.EdsRelease(stream);
            var bitmap = new Bitmap(outputSize.width, outputSize.height, Stride, PixelFormat.Format24bppRgb,
                                    streamPointer);
            byte[] byteArray = new byte[0];
            using (MemoryStream memostream = new MemoryStream())
            {
                bitmap.Save(memostream, ImageFormat.Bmp);
                memostream.Close();

                byteArray = memostream.ToArray();
            }
            return byteArray;
        }
Exemplo n.º 4
0
        public static uint EdsGetPropertyData(IntPtr inRef, uint inPropertyId, int inParam,
             out Edsdk.EdsTime outPropertyData)
        {
            int size = Marshal.SizeOf(typeof(Edsdk.EdsTime));
            IntPtr ptr = Marshal.AllocHGlobal(size);
            uint err = EdsGetPropertyData(inRef, inPropertyId, inParam, size, ptr);

            outPropertyData = (Edsdk.EdsTime)Marshal.PtrToStructure(ptr, typeof(Edsdk.EdsTime));
            Marshal.FreeHGlobal(ptr);
            return err;
        }