Arsip: JPEG error #41

more 14 years ago
dakocan
apa sich maksudnya JPEG error#41?????????????????????????????
saya pake database mysql

more 14 years ago
LuriDarmawan
@dakocan,
tolong dong... kalo ngisi subjek mohon disesuaikan dengan isi materi.
mmm... sy yakin eror ini bukan karena mysql-nya.
tp lebih pada karena dataimage yg kacau waktu di simpan di blob.
ini copy paste dari dokumen sy
From: wir97jkd@studserv.uni-leipzig.de (Kay Schubert)
Subject: Re: Prevent JPEG Error 41!?
Date: 09 May 1999 00:00:00 GMT
Message-ID: <3735ee86.23139803@forums.inprise.com>
References: <37261381.B123FF9F@t-online.de>
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.delphi.graphics
On Tue, 27 Apr 1999 21:44:02 +0200, Michael Bauer
<BauerSoft@t-online.de> wrote:
>In my Application, its possible that there is
>no JpegImage inside my BlobField.
Instead of explicitely save a TJpegImage to your Blobfield, use code
below, which lets TPicture do the work.
This code saves and loads ALL TPicture-contained TGraphic descendents
into and from a stream, without any need to know its actual type. This
means, you can use TPicture.LoadFromFile to load ANY graphics format
(provided it is registered via TPicture.RegisterFileFormat, of
course).
TPictureFiler = class(TFiler)
public
ReadData: TStreamProc;
WriteData: TStreamProc;
constructor Create; overload;
procedure DefineProperty(const Name: string;
ReadData: TReaderProc; WriteData: TWriterProc;
HasData: Boolean); override;
procedure DefineBinaryProperty(const Name: string;
ReadData, WriteData: TStreamProc;
HasData: Boolean); override;
procedure FlushBuffer; override;
end;
// Since I use TFiler only partially, the inherited constructor
TFiler.Create is unnecessary, so I use this dummy
constructor TPictureFiler.Create;
begin
end;
//will be called by TPicture, handing over the private methods to
read/write TPicture from/to Stream
procedure TPictureFiler.DefineBinaryProperty(const Name: string;
ReadData,WriteData: TStreamProc; HasData: Boolean);
begin
if Name = 'Data' then begin
Self.ReadData := ReadData;
Self.WriteData := WriteData;
end;
end;
procedure TPictureFiler.DefineProperty(const Name: string;
ReadData: TReaderProc; WriteData: TWriterProc; HasData: Boolean);
begin
//at this time TPicture don't call this function
//only implemented as precaution to (unlikely) changes in future
delphi versions
end;
procedure TPictureFiler.FlushBuffer;
begin
//at this time TPicture don't call this function
//only implemented as precaution to (unlikely) changes in future
delphi versions
end;
// Wrapper to call protected TPicture.DefineProperties
// must be in same unit as ReadWritePictureFromStream
type
TMyPicture = class(TPicture)
end;
procedure ReadWritePictureFromStream(Picture: TPicture; Stream:
TStream;
Read: Boolean);
var
Filer: TPictureFiler;
begin
Filer := TPictureFiler.Create;
try
//TPicture.DefineProperties is protected, but TMyPicture is
declared
in this unit
//TMyPicture's protected members (also the inherited) are public
to
this unit
TMyPicture(Picture).DefineProperties(Filer);
//TPicture.DefineProperties calls Filer.DefineBinaryProperty
if Read then
Filer.ReadData(Stream) //TPicture does the work
else
Filer.WriteData(Stream); //TPicture does the work
finally
Filer.Free;
end;
end;
//whatever TIcons actual image size, its LoadFromStream(Stream:
TStream)
reads just to the end of the stream
//if I have additional things after TIcon streamed, they are lost
after
TIcon.LoadFromStream
//so I store the actual size before in the stream
procedure WritePictureToStream(Picture: TPicture; Stream: TStream);
var
MStream: TMemoryStream;
iPictureSize: Integer;
begin
MStream := TMemoryStream.Create;
try
ReadWritePictureFromStream(Picture, MStream, False); //store
TPicture data in TMemoryStream
iPictureSize := MStream.Size;
Stream.WriteBuffer(iPictureSize, sizeof(iPictureSize));//store
size
of TPicture data in TStream
Stream.WriteBuffer(MStream.Memory^, iPictureSize);//store
TMemoryStream(containing TPicture data) in TStream
finally
MStream.Free;
end;
end;
procedure ReadPictureFromStream(Picture: TPicture; Stream: TStream);
var
MStream: TMemoryStream;
iPictureSize: Integer;
begin
MStream := TMemoryStream.Create;
try
Stream.ReadBuffer(iPictureSize, sizeof(iPictureSize));//read size
of
TPicture data
MStream.SetSize(iPictureSize);//adjust buffer size
Stream.ReadBuffer(MStream.Memory^, iPictureSize);//get TPicture
data
//why TMemoryStream ? See what I said above about TIcon
ReadWritePictureFromStream(Picture, MStream, True);//read TPicture
data
finally
MStream.Free;
end;
end;
//Now WritePictureToStream and ReadPictureFromStream could be used to
save/load any TPicture to/from any TStream.
//example (in pseudo code):
TStream := TDataSet.CreateBlobStream(TBlobField, bmWrite);
try
WritePictureToStream(TPicture, TStream);
finally
TStream.Free;
end;
TStream := TDataSet.CreateBlobStream(TBlobField, bmRead);
try
ReadPictureFromStream(TPicture, TStream);
finally
TStream.Free;
end;
//perhaps this looks a bit tricky, but I think changes to VCL and
TPicture streaming system are very unlikely.
thx.
more 14 years ago
dakocan
sorry yah, bang luri, saya nggak ngasih subjek yg jelas.
dari source bang luri, gua bingung caranya make !!!
tapi saya pake source dari kaka-delphi, membaca gambar jpg dgn menggunakan zeos
procedure TForm1.TampilkanGambarJPG(img: TImage);
var
Jpg: TJpegImage;
Ms : TMemoryStream;
begin
Jpg := TJpegImage.Create;
Ms := TMemoryStream.Create;
ZTable1Foto.SaveToStream(Ms);
Ms.Position := 0;
Jpg.LoadFromStream(Ms);
{ Tampilkan gambar dr tabel ke Image1 }
img.Picture.Graphic := Jpg;
Jpg.Free;
Ms.Free;
end;
ketika saya aktifkan tabel mis: ZTable1.active:=true; maka akan muncul jpeg error#41,kalo data di mysqlnya masih kosong.
mohon pencerahannya

more 14 years ago
x_adhy20
jpeg error#41terjadi karna eksekusi jpg.loadfromstream tidak menemukan gambar jpeg dalam tabel anda, solusinya jgn eksekusi jpg.loadfromstream kalau tabel kosong (gambar tidak ada)

more 11 years ago
wahyudi_delphi
bagi teman-teman yang belum menemukan solusinya:
procedure TForm1.TampilkanGambar;
var
Jpg: TJpegImage;
Ms : TMemoryStream;
begin
Jpg := TJpegImage.Create;
Ms := TMemoryStream.Create;
Table1Foto. SaveToStream(Ms);
Ms.Position := 0;
{yudi} if Ms.Size<>0 then begin
Jpg.LoadFromStream(Ms);
{ Tampilkan gambar dr tabel ke Image1 }
Image1.Picture.Graphic := Jpg;
Jpg.Free;
{yudi}end;
Ms.Free;
end;
CMIIWmore ...
- Pages:
- 1
reply |
Report Obsolete
Last Articles
- Project Group dalam Lazarus
- FastPlaz Database Explorer
- Release: FastPlaz Super Mom v0.12.22
- PascalClass #3: Web Development with Free Pascal
- Makna Pascal di Pascal Indonesia
- Kulgram : Instalasi Lazarus di Perangkat Berbasis ARM
- PascalClass #1: Analisa Database dan Machine Learning
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
- Mengenal OXYGENE – Pascal For .NET
- PascalTalk #5: UX: Research, Design and Engineer
Last Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 3 months ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 3 months ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 4 months ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 4 months ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 4 months ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 4 months ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 1 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 8 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 8 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 8 years ago
Random Topic
- OnCloseQuery
by o-dad in Tip n Trik Pemrograman more 12 years ago - Speech Engine
by clark in Hal umum tentang Pascal Indonesia more 14 years ago - OOT: TRAWPrinter adakah yg sudah coba
by imunk in OOT more 14 years ago - Nanya hak akses hanya pada record tertentu
by greatjon2002 in MySQL more 14 years ago - Insert date
by zones in MsSQL more 13 years ago - instalasi 3rd komponen
by grounders in Hal umum tentang Pascal Indonesia more 15 years ago - Get Tablename di Zeos ???
by Manz in Tip n Trik Pemrograman more 13 years ago - Firebird 2.0 Released!
by simba in FireBird more 14 years ago - Merubah Regional Settings
by ZeAL in Tip n Trik Pemrograman more 14 years ago - mo nanya2 tentang hirarki grid.....
by gandungtjakep in Hal umum tentang Pascal Indonesia more 11 years ago