Recent

Author Topic: Using Camera  (Read 29770 times)

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2583
Re: Using Camera
« Reply #15 on: August 18, 2009, 11:12:15 am »
i write the value of it in a label or memo with the strpas function (array to string conversion)... also according to the MSDN this variable should contain the complete path of the file (photo/video) that you capture. Even if i managed, finally, to get the file... it is always saved under the default location (my documents\my pictures) and the szfile variable contains a '\' string only.
That's what I thought. StrPas only handles Ansi characters, while CE uses WideChars. So StrPas sees a #0 after the first \
Use some WideChar to UTF8 conversion to display it in Lazarus (I don't recall the name of the function)
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

xqtr

  • New Member
  • *
  • Posts: 21
Re: Using Camera
« Reply #16 on: August 18, 2009, 02:37:14 pm »
I figure it out... so here it is...

This is a way to get a photo, without invoking the Camera application of the windows mobile phone. To use it, add to your uses the capstill unit and copy the .dll file to your application directory or inside the \windows dir of the WM phone.

You can make a capture with the code below, just add it to a button click or something else.

Code: [Select]
if InitGraph(form1.handle) then CaptureStill(widestring('\My Documents\image1.jpg'));

The file must not pre-exist or the function will fail.

BlueIcaro

  • Hero Member
  • *****
  • Posts: 792
    • Blog personal
Re: Using Camera
« Reply #17 on: August 18, 2009, 05:15:57 pm »
Thank you for the post, I tested in WM6 emulator and it's works, but in my PocketPc Hp rx3715 with WM5 says me that the project is not a valid application  :'(

/BLueIcaro

Edit: I copy the .exe file and the .dll file to the storage card
« Last Edit: August 18, 2009, 06:24:48 pm by BlueIcaro »

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2583
Re: Using Camera
« Reply #18 on: August 19, 2009, 12:27:10 pm »
To avoid the widestring cast, you can declare CaptureStill like
Code: [Select]
Function CaptureStill(filename:pwidechar):boolean; stdcall; external 'mobilecamera.dll' name 'CaptureStill';
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

classic12

  • New Member
  • *
  • Posts: 19
Re: Using Camera
« Reply #19 on: February 11, 2010, 08:41:28 pm »
Anyone have a sample app for the above code or simple step by step instructions on how to use.


Cheers


SteveW

classic12

  • New Member
  • *
  • Posts: 19
Re: Using Camera
« Reply #20 on: February 15, 2010, 07:48:42 pm »
Okay for anyone else using this I created a new application. with a button with:

if InitGraph(form1.handle) then CaptureStill(widestring('\My Documents\image1.jpg'));

Put the dll & capstill.pas in the same directory.

It worked ......... :D

I now need to develope this and add functionality to it. Some questions.

1. Can I pass parameters to the request IE resolution / flash / brightness etc etc.
2. Is it possible to have a preview of the camera ?


Any info appreciated.


Cheers


SteveW

classic12

  • New Member
  • *
  • Posts: 19
Re: Using Camera
« Reply #21 on: February 15, 2010, 08:32:10 pm »
Sorry also added capstill.pas to the uses clause.

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  StdCtrls, capstill;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
  if InitGraph(form1.handle) then CaptureStill(widestring('\My Documents\image1.jpg'));
end;

initialization
  {$I unit1.lrs}

end.
               

classic12

  • New Member
  • *
  • Posts: 19
Re: Using Camera
« Reply #22 on: February 15, 2010, 08:44:44 pm »
I tried adding the capstill.pas to a basic KOL project and I get this error:

unit1.pas(68,26) Error: identifier idents no member "handle"

if InitGraph(form1.handle) then CaptureStill(widestring('\My Documents\image1.jpg')); 


Any ideas?


Cheers


SteveW

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Using Camera
« Reply #23 on: February 26, 2010, 01:12:05 pm »
i write the value of it in a label or memo with the strpas function (array to string conversion)... also according to the MSDN this variable should contain the complete path of the file (photo/video) that you capture. Even if i managed, finally, to get the file... it is always saved under the default location (my documents\my pictures) and the szfile variable contains a '\' string only.

Maybe you are using the wrong string type. WinCE usually uses PWideChar and not PChar. You have to check what exactly the API is using and also the encoding and convert property to a utf-8 pascal string to show in a Label.

ldb68

  • Newbie
  • Posts: 1
Re: Using Camera
« Reply #24 on: December 19, 2011, 08:39:25 am »
Found sample on previous post.

thanks

Where I can find capstill.pas?

thanks


Sorry also added capstill.pas to the uses clause.

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  StdCtrls, capstill;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
  if InitGraph(form1.handle) then CaptureStill(widestring('\My Documents\image1.jpg'));
end;

initialization
  {$I unit1.lrs}

end.
               
« Last Edit: December 19, 2011, 09:44:58 am by ldb68 »

 

TinyPortal © 2005-2018