Ver Mensaje Individual
  #1  
Antiguo 23-11-2023
darkamerico darkamerico is offline
Miembro
 
Registrado: dic 2010
Posts: 233
Reputación: 14
darkamerico Va por buen camino
Red face Usar el componente cxImageSlider desde campos BLOB en Absolute Database

Saludos amigos,

Esta es mi Unidad:

Código Delphi [-]
unit uMain;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, DB, cxGraphics, cxControls,
  cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore, dxSkinBlack, dxSkinBlue,
  dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide,
  dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
  dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
  dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis,
  dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black,
  dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink,
  dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue,
  dxSkinOffice2010Silver, dxSkinOffice2013DarkGray, dxSkinOffice2013LightGray,
  dxSkinOffice2013White, dxSkinOffice2016Colorful, dxSkinOffice2016Dark,
  dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus,
  dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008,
  dxSkinTheAsphaltWorld, dxSkinTheBezier, dxSkinsDefaultPainters,
  dxSkinValentine, dxSkinVisualStudio2013Blue, dxSkinVisualStudio2013Dark,
  dxSkinVisualStudio2013Light, dxSkinVS2010, dxSkinWhiteprint,
  dxSkinXmas2008Blue, Vcl.StdCtrls, dxImageSlider, dxGDIPlusClasses, ABSMain,
  cxClasses;

type
  TForm1 = class(TForm)
    dxImageSlider1: TdxImageSlider;
    Button1: TButton;
    DB: TABSDatabase;
    q_Imagenes: TABSQuery;
    cxImageCollection1: TcxImageCollection;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    procedure CargarImagenesDesdeBLOB(dxImageSlider: TDxImageSlider; dataset: TAbsQuery);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.CargarImagenesDesdeBLOB(dxImageSlider: TDxImageSlider; dataset: TAbsQuery);
var
  imagen: TdxSmartImage;
  stream: TMemoryStream;
  blob:TBlobField;
  ImgItem: TcxImageCollectionItem;
  i:byte;
begin
  //dxImageSlider.Images.BeginUpdate;
  try
    dataset.Close;
    dataset.Open;
    dataset.First;
    i:=0;
    while not dataset.Eof do
    begin
      stream := TMemoryStream.Create;
      try
        blob:=TBlobField(dataset.FieldByName('sw_screen1'));
        blob.SaveToStream(stream);
        stream.Position := 0;
        ImgItem := TcxImageCollectionItem.Create(Self);
        ImgItem.Picture.LoadFromStream(Stream);

        dxImageSlider.Images.Items[i]:=ImgItem;

        Inc(i);
      finally
        stream.Free;
      end;
      dataset.Next;
    end;
  finally
    //dxImageSlider.Images.EndUpdate;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  CargarImagenesDesdeBLOB(dxImageSlider1, q_Imagenes);
end;

end.

Obtengo error dentro de la funcion CargarImagenesDesdeBLOB() en la línea ImgItem.Picture.LoadFromStream(Stream);
El mensaje de error es: Unsupported stream format.

La tabla de Absolute Database tiene campos BLOB con imágenes JPG en 4 campos: sw_screen1, sw_screen2, sw_screen3, sw_screen4.

Lo que necesito es que esos 4 imagenes se puedan ver en un componente DxImageSlider.

Agradeceré mucho su ayuda.


Abrazo
Responder Con Cita