Ver Mensaje Individual
  #5  
Antiguo Hace 13 Horas
aposi aposi is offline
Miembro
 
Registrado: dic 2006
Posts: 161
Reputación: 20
aposi Va por buen camino
segun claude prueba esto:


Código:
#include <jpeg.hpp>

void __fastcall TForm1::DetailBand1BeforePrint(TQRCustomBand *Sender, bool &PrintBand)
{
    ImgInf->Picture->Assign(NULL);   // evita que se arrastre la imagen del registro anterior

    TBlobField *campo = dynamic_cast<TBlobField*>(Query->FieldByName("Caratula"));
    if (campo == NULL || campo->IsNull)
        return;

    TMemoryStream *ms = new TMemoryStream;
    try
    {
        campo->SaveToStream(ms);
        if (ms->Size < 4)
            return;

        unsigned char cab[4];
        ms->Position = 0;
        ms->ReadBuffer(cab, 4);
        ms->Position = 0;

        if (cab[0] == 0xFF && cab[1] == 0xD8)          // JPEG
        {
            TJPEGImage *jpg = new TJPEGImage;
            try
            {
                jpg->LoadFromStream(ms);
                Graphics::TBitmap *bmp = new Graphics::TBitmap;
                try
                {
                    bmp->Assign(jpg);                  // convertimos a BMP: QR lo imprime sin problemas
                    ImgInf->Picture->Assign(bmp);
                }
                __finally { delete bmp; }
            }
            __finally { delete jpg; }
        }
        else if (cab[0] == 'B' && cab[1] == 'M')       // BMP
        {
            ImgInf->Picture->Bitmap->LoadFromStream(ms);
        }
        // Otros formatos (PNG, GIF...) no los soporta BCB6 de serie: se deja la imagen vacía
    }
    __finally
    {
        delete ms;   // en tu código original el stream no se liberaba nunca
    }
}
Responder Con Cita