Ver Mensaje Individual
  #5  
Antiguo 17-07-2017
JXJ JXJ is offline
Miembro
 
Registrado: abr 2005
Posts: 2.475
Reputación: 21
JXJ Va por buen camino
Muchisimas Gracias _Leo

no vi que faltara la ,

y lo del resto tambien me ayuda mucho.

probe el codigo y si funciona,, :

Que dicha.
la cosa rara con los ansi string , es por que es la unica forma que encontre de pasar el unicodestring del edit
a la funcion de la libreria que solo acepta ansi o de tipo char* , no soy bueno en c++ por eso es que hize esa cosa rara

aparte de que la lib qricol se compila con c++ de visual studio.
y la dll el autor de qrcol la da con un wrapper para delphi.
la recomendacion es usarlo con versiones delphi que soportan unicode

y la png y zlib y jpeg, las compile con c++ builder xe6


Buen dia. ;D

header
Código PHP:
//---------------------------------------------------------------------------

#ifndef FrmMainUH
#define FrmMainUH

//#define MiSRCCOPY              (DWORD)0x00CC0020 /* dest = source*/
     #define BitBltRopMode_WinNT (DWORD)0x00CC0020 or SRCCOPY;
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <System.Actions.hpp>
#include <Vcl.ActnList.hpp>
#include <Vcl.Dialogs.hpp>
#include <Vcl.ExtCtrls.hpp>
#include <Vcl.Menus.hpp>
#include <Vcl.Samples.Spin.hpp>
#include <Winapi.Windows.hpp>
#include <System.SysUtils.hpp>
#include <Vcl.Imaging.jpeg.hpp>
#include "../include/qrcode/quricol.h"
//---------------------------------------------------------------------------
class TFrmMainF : public TForm
{
__published:    // IDE-managed Components
    
TShape *Shape1;
    
TLabel *Label1;
    
TBevel *Bevel1;
    
TImage *imgCode;
    
TLabel *Label2;
    
TLabel *Label3;
    
TEdit *edtText;
    
TSpinEdit *edtMargin;
    
TSpinEdit *edtSize;
    
TActionList *ActionList1;
    
TAction *actClose;
    
TAction *actSave;
    
TAction *actCreate;
    
TAction *actCopy;
    
TSaveDialog *SaveDialog;
    
TPopupMenu *PopupMenu1;
    
TMenuItem *Opslaan1;
    
TMenuItem *Kopierennaarhetklembord1;
    
TButton *btnCreate;
    
TButton *btnSave;
    
TButton *BtnClose1;
    
TButton *Button1;
    
TMemo *Memo1;
    
void __fastcall actCloseExecute(TObject *Sender);
    
void __fastcall actSaveExecute(TObject *Sender);
    
void __fastcall Button1Click(TObject *Sender);
[
bGraphics::TBitmap__fastcall GetBitmapImage(String TextoToImgQRCodeint Marginint PixelSizeint Level );[/b]
private:    
// User declarations
public:        // User declarations
    
__fastcall TFrmMainF(TComponentOwner);
};
//---------------------------------------------------------------------------
extern PACKAGE TFrmMainF *FrmMainF;
//---------------------------------------------------------------------------
#endif 
implementacion corregida
Código PHP:


Graphics
::TBitmap__fastcall TFrmMainF::GetBitmapImage(String TextoToImgQRCodeint Marginint PixelSizeint Level )
    {
      
HBITMAP Bmp;
      
TDIBSection DIB;
//      THandle ScreenDC;
//     THandle DC;

        
String TextoToQR TextoToImgQRCode;
            
char *TextoToQRImg AnsiString(TextoToQR).c_str()  ;

       
Bmp GetHBitmapA(TextoToQRImgMargin,PixelSizeLevel)  ;
       
GetObjectA(Bmpsizeof(DIB), &DIB);

       
Graphics::TBitmap *Result = new Graphics::TBitmap;
       
Result->Width DIB.dsBmih.biWidth;
       
Result->Height DIB.dsBmih.biHeight;
       
Result->PixelFormat pf32bit;

     
HDC  ScreenDC GetDC(0);
     
HDC DC CreateCompatibleDC(ScreenDC);
     
SelectObject(DCBmp);
     
ReleaseDC(0ScreenDC);


     
BitBlt(Result->Canvas->Handle0,0Result->WidthResult->HeightDC0,0,  SRCCOPY);// da error no se por que
     
DeleteDC(DC);
     
DeleteObject(Bmp);

     return 
Result;
    } 
procedure donde la uso
Código PHP:


void __fastcall TFrmMainF
::actSaveExecute(TObject *Sender)
{
 
String Ext;
 
TJPEGImage *Jpg = new TJPEGImage();
 
TBitmap *= new TBitmap;
     
/*
 if SaveDialog.Execute then
   begin
     Ext := ExtractFileExt(SaveDialog.FileName);
     if SameText(ext, '.png') then
       TQRCode.GeneratePngFile(SaveDialog.FileName, edtText.Text, edtMargin.Value, edtSize.Value){este es el de interes gdmx como guardar como png}
     else if SameText(ext, '.bmp') then
       TQRCode.GenerateBitmapFile(SaveDialog.FileName, edtText.Text, edtMargin.Value, edtSize.Value)
     else
       begin
         Jpg := TJPEGImage.Create;
         B := TQRCode.GetBitmapImage(edtText.Text, edtMargin.Value, edtSize.Value);
         Jpg.Assign(B);
         B.Free;
         Jpg.SaveToFile(SaveDialog.FileName);
         Jpg.Free;
       end;
   end;                 */
    
if (SaveDialog->Execute() )
    {
        
Memo1->Lines->Add("nombrearch SAVEEXecute " SaveDialog->FileName);
      
Ext ExtractFileExt(SaveDialog->FileName);
            
Memo1->Lines->Add("estension saveexe" Ext);
       if(
SameText(Ext,".png"))
       {
         
String NameFile SaveDialog->FileName;
            
char *NameFileOD AnsiString(NameFile).c_str();

            
String TextoToQR edtText->Text;
            
char *TextoToQRImg AnsiString(TextoToQR).c_str()  ;

            
Memo1->Lines->Add(Ext);
                                    
Memo1->Lines->Add("dentro de png SAVEEXecute " SaveDialog->FileName);
//          GeneratePNGW(  SaveDialog->FileName.c_str(), edtText->Text.c_str(),   edtMargin->Value, edtSize->Value,3) ;
          
GeneratePNGA(  NameFileOD      ,  TextoToQRImg  ,   edtMargin->ValueedtSize->Value,3) ;
       }
       else if (
SameText(Ext".bmp"))
       {
          
String NameFile SaveDialog->FileName;
            
char *NameFileOD AnsiString(NameFile).c_str();

            
String TextoToQR edtText->Text;
            
char *TextoToQRImg AnsiString(TextoToQR).c_str()  ;
         
GenerateBMPA(  NameFileOD      ,  TextoToQRImg  ,   edtMargin->ValueedtSize->Value,3) ;
       }
       else
       {
            
String NameFile SaveDialog->FileName;
            
char *NameFileOD AnsiString(NameFile).c_str();

            
String TextoToQR edtText->Text;
            
char *TextoToQRImg AnsiString(TextoToQR).c_str()  ;

              
=  GetBitmapImage(TextoToQRImgedtMargin->ValueedtSize->Value);
               
Jpg->Assign(B);
               
B->Free();
               
Jpg->SaveToFile(SaveDialog->FileName);
               
Jpg->Free();
       }
    }


Responder Con Cita