English
Forum

GDI+

 

Georg
Hovenbitzer
Hello together,

me erdrückt straight a gigantic Wissenslücke what about me hope your can me help on.
target is it, one Image To loading, it to a Thumbnail To verkleiner and then in a data base to take off.
my trouble is now the part between Thumbnail and Database and there the, How I a Speicheradresse / aray the Bildes and which Size come:
as Presentation have I the geile GDI+ demonstration of Andreas taken.
 $H \windows.ph
 $H \includes\Functions_GDIPLUS.ph
 $H \includes\GDIP_Imageging.ph
 $I \includes\GDIP_Helper.inc
Declare gdiplusToken&,ImageObject&,ImageWidth&,ImageHeight&,GraphicObject&
Declare hPic&
Declare imgThumb&
Declare lngImage&
Declare hBitmap&
Window 0,0-1024,786
Cls ~GetSysColor(~COLOR_3DFACE)
gdiplusToken& = InitGDIPlus()
hPic& = @Create(hPic,-1,Image.jpg)
~GdipCreateBitmapFromHBITMAP(hPic&,0,@Addr(lngImage&))
~GdipGetImageThumbnail(lngImage&,92,69,@Addr(imgThumb&),0,0)
~GdipCreateHBITMAPFromBitmap(imgThumb&,@Addr(hBitmap&))
DrawPic hBitmap&,50,50;0
here bräuchte I now something, what me a address or aray and which Size determined !!!
WaitInput
DeleteObject hPic&
DeleteObject hBitmap&
~GdipDisposeImage(imgThumb&)
~GdipDisposeImage(lngImage&)
ExitGDIPlus(gdiplusToken&)
End
 
Viele Grüsse, Georg Hovenbitzer(Windows XP Pro, XProfan 11.2, Profan2Cpp 1.6a)
02/02/09  
 



I faith here [...]  ./. here [...]  standing The Solution.

i'd probably the Thumbs by XProfan11s hPic-functions produce, and the couple Pixel the Thumbs by z.B. inlineasm or Ner small DLL abpixeln, if the DIB-Krahm not wants. *g*
 
02/02/09  
 




Georg
Hovenbitzer
Hello if,

thanks for left, will be tappt im dunkeln me same time accurate standing.
with XProfan11 begot Thumbnails are from the quality not the Hit, there must one then first once more a Weichzeichner drüber run, no tidy Solution.
Per GDI+ could I tappt im dunkeln to Time already abspeichern and then simply again new reading and The data base Save.
but i'd it gladly create without this detour, mere circa what To learn.
time see Perhaps come I with the left Yes clear or it has someone yet a hint!

Nachtrag:
I have me both Demos time respected, unfortunately help tappt im dunkeln I do not moreover.
unfortunately come I no brauchbare address and which Size circa by BlockWrite WinXP? wegzuschreiben.
 
Viele Grüsse, Georg Hovenbitzer(Windows XP Pro, XProfan 11.2, Profan2Cpp 1.6a)
02/02/09  
 




Uwe
''Pascal''
Niemeier
Hi Georg!

have here a old routine found and on The speedy angepaßt; so can itself one bmp-lever in Bilddaten decompose. Perhaps hilf the what:
CompileMarkSeparation
window 30,30-500,500
 $H Windows.ph
declare a#,b#
declare Pic$,Handle&,Neu&
---------------------------------Diesen Pfad bitte anpassen!
Pic$=C:Dokumente und EinstellungenPascalDesktopBild.jpg
Handle&=create(hPic,-1,Pic$)--Liefert immer 32-Bit-Handle!
--BITMAPINFOHEADER-Struktur
--Nur benötigte Parameter wurden bezeichnet
struct bmpHEADER=Size&,Width&,Height&,Planes%,BitCount%,Compression&,SizeImage&,X#(24)
dim a#,bmpHEADER
a#.Size&=sizeof(a#)------------------Größe von BITMAPINFOHEADER
~GetDIBits(%hdc,Handle&,0,0,0,a#,0)--Dummy-Aufruf, um bmpHeader zu füllen (Rückgabe: 1=OK)
dim b#,a#.SizeImage&-----------------Bereich für Bildinformationen (Pixel) bereitstellen
~GetDIBits(%hdc,Handle&,0,a#.Height&,b#,a#,0)--Eigendliche Bilddaten aus Handle ermitteln
Neu&=~CreateDIBitmap(%hdc,a#,4,b#,a#,0)------Neue DIB mit geänderten Farben erzeugen
drawpic Neu&,10,10;0
dispose a#
dispose b#
waitkey

BTW: That the quality (create(hSizedPic... ?)is me not yet aufgefallen; but GDI+ is explicit faster.
BTW2: Kriegst You The (binären) data because at all into DB? can me dark remind, that some DBs non-ASCII-data ignore or transfiguring.

HTH
Pascal
 
02/02/09  
 




Georg
Hovenbitzer
Hello Pascal,

many Thanks for Tipp.
but I come lest integrally clear, I have of course now The Size the Bitmaps and a aray, but the again Abspeichern skin not there.
In my example have I the lever of erstellten Thumbnail and could now with the of Andreas written function SaveAsJPG the image too abspeichern. moreover using it in its function GdipSaveImageToFile! it may be, that The function GdipSaveImageToStream the right for me is, have but no idea How one tappt im dunkeln correctly. einsetzt.

greetings
Georg
 
Viele Grüsse, Georg Hovenbitzer(Windows XP Pro, XProfan 11.2, Profan2Cpp 1.6a)
02/02/09  
 




Uwe
''Pascal''
Niemeier
Hi Georg!

Related to the Save ought to no trouble his - mind you in a File!
but I ahne slow, on what You hinauswillst: You want a JPG-File in memory produce and the then into DB insert, correctly.? (where To deliberating is, that Image-Handles  always Bitmap-basiert are)

Related to the Stream could klappen, is not einfach; Streams are COM-Objects and lest slight To manage. Also remaining yet The question, whether and How You The Binärdaten into DB kriegst.

an alternative would, The Thumbs in a ImageList To pack and these as a  File (parallel to DB) abzuspeichern. in the DB would then only one index aufs Image the ImageList vermerkt. have I already successful practising

Perhaps verwendest You but too a DB, The of House from Images include kann; then should one The thing with ActiveX / VBA concern.

or even the ploy with the DataGenerator

HTH
Pascal
 
02/03/09  
 




Georg
Hovenbitzer
Hello Pascal,

very this was my idea, around the detour the Speichers in a File To bypass.
I have plenty Internet sought and I found have, saw everything else as simply from.
this would an example [...]  where one Image end in a byte aray alights and of there could one it in a DB write. but any my try it nachzubauen are gescheiter, there me here too the deeper Grundwissen missing.
I have me with SQLite befasst and could there without Problems JPG Images in Blob boxes take off and again herausholen.
If you yet a Tipp have always since so
 
Viele Grüsse, Georg Hovenbitzer(Windows XP Pro, XProfan 11.2, Profan2Cpp 1.6a)
02/03/09  
 



small question to! such one z.B. 48x48 JPG 60% ought to under 1 KB data need, means too base64-kodiert no trouble...

means Why not simply complete JPG (681 byte) loading? var meinString$=[decode64](jpgDateiInhalt) ?


1 kB
Hochgeladen:02/03/09
Downloadcounter134
Download
 
02/03/09  
 




Thomas
Freier
alas Georg, verrate us still once whom Datenbanktyp: dBaseV.dbf, access.mdb with Ole-area or HiPer-Six.dbf,FoxPro.dbf with Blob-area or ???
The named can sure with too about sql machine go.
and in your Info becomes on :


for the function PictureToString becomes The IStream.TLB
of madmax needed and is in this Download include.


verwiesen.
 
Gruß Thomas
Windows XP SP2, XProfan X2
02/04/09  
 




Georg
Hovenbitzer
Hello together,

It's all right me not only therefore the Thumbnails in a data base To Save, separate too The original Images.
with the Original is this no trouble, I it by BlockRead reading and so into Blob area abspeichern can.
with whom Thumbnails is it differently, there tappt im dunkeln Yes first prepares and be therefore only as Bitmap in memory exist, this must first Yes still in one JPG stature gestreamt and be then can I it take off. the Streamen goes if I the Bitmap with GdipSaveImageToFile abspeichere, for there Vorlagen.
one can now the gespeicherte Thumbnail again reading and The data base Save, only this would I me gladly save, alone to see as goes.

enclosed time one demonstration How one with SQLite one presentment in a data base ablegt, The benötigte DLL get one with SQLite.
the demonstration places a DB on, invites Image, save this into DB, reads it again from and memory it and a others names ex.
The expenses on-screen only Statusmeldungen, it go too no Error abgefangen.
Paths Please adjust.
CompileMarkSeparation
Def ZeroMemory(2) !KERNEL32,RtlZeroMemory
Def MoveMemory(3) !KERNEL32,RtlMoveMemory
Def WriteFile(5) !KERNEL32,WriteFile
Def CreateFile(7) !KERNEL32,CreateFileA
Def ReadFile(5) !KERNEL32,ReadFile
Def OpenFile(3) !KERNEL32,OpenFile
Def GetFileSizeAPI(2) !KERNEL32,GetFileSize
Def CloseHandle(1) !KERNEL32,CloseHandle
Def &SQLITE_OK           0/* Successful result */
Def &SQLITE_ERROR        1/* SQL error or missing database */
Def &SQLITE_INTERNAL     2/* Internal logic error in SQLite */
Def &SQLITE_PERM         3/* Access permission denied */
Def &SQLITE_ABORT        4/* Callback routine requested an abort */
Def &SQLITE_BUSY         5/* The database file is locked */
Def &SQLITE_LOCKED       6/* A table in the database is locked */
Def &SQLITE_NOMEM        7/* A malloc() failed */
Def &SQLITE_READONLY     8/* Attempt to write a readonly database */
Def &SQLITE_INTERRUPT    9/* Operation terminated by sqlite3_interrupt()*/
Def &SQLITE_IOERR       10/* Some kind of disk I/O error occurred */
Def &SQLITE_CORRUPT     11/* The database disk image is malformed */
Def &SQLITE_NOTFOUND    12/* NOT USED. Table or record not found */
Def &SQLITE_FULL        13/* Insertion failed because database is full */
Def &SQLITE_CANTOPEN    14/* Unable to open the database file */
Def &SQLITE_PROTOCOL    15/* NOT USED. Database lock protocol error */
Def &SQLITE_EMPTY       16/* Database is empty */
Def &SQLITE_SCHEMA      17/* The database schema changed */
Def &SQLITE_TOOBIG      18/* String or BLOB exceeds size limit */
Def &SQLITE_CONSTRAINT  19/* Abort due to constraint violation */
Def &SQLITE_MISMATCH    20/* Data type mismatch */
Def &SQLITE_MISUSE      21/* Library used incorrectly */
Def &SQLITE_NOLFS       22/* Uses OS features not supported on host */
Def &SQLITE_AUTH        23/* Authorization denied */
Def &SQLITE_FORMAT      24/* Auxiliary database format error */
Def &SQLITE_RANGE       25/* 2nd parameter to sqlite3_bind out of range */
Def &SQLITE_NOTADB      26/* File opened that is not a database file */
Def &SQLITE_ROW         100/* sqlite3_step() has another row ready */
Def &SQLITE_DONE        101/* sqlite3_step() has finished executing */
Def &SQLITE_OPEN_READONLY         $00000001
Def &SQLITE_OPEN_READWRITE        $00000002
Def &SQLITE_OPEN_CREATE           $00000004
Def &SQLITE_OPEN_DELETEONCLOSE    $00000008
Def &SQLITE_OPEN_EXCLUSIVE        $00000010
Def &SQLITE_OPEN_MAIN_DB          $00000100
Def &SQLITE_OPEN_TEMP_DB          $00000200
Def &SQLITE_OPEN_TRANSIENT_DB     $00000400
Def &SQLITE_OPEN_MAIN_JOURNAL     $00000800
Def &SQLITE_OPEN_TEMP_JOURNAL     $00001000
Def &SQLITE_OPEN_SUBJOURNAL       $00002000
Def &SQLITE_OPEN_MASTER_JOURNAL   $00004000
Def &SQLITE_OPEN_NOMUTEX          $00008000
Def &SQLITE_OPEN_FULLMUTEX        $00010000
Def &SQLITE_STATIC 0
Def &SQLITE_TRANSIENT -1
Declare Datei$
Declare hDLL&
Declare dll$
Declare DBName$
Declare hDB&
Declare Error&
Declare SQLCmd$
Declare Result&
Declare Titel$[]
Declare Titel$
Declare Titel&
Declare zKey$
Declare zBlob#
Declare nBlob&
Declare pnBlob&
Declare pzBlob#
Declare BWrite&
Declare FBuf#
Declare FHdl&
Declare FSize&
Window 0,0-1024,786
@Set(CallConv,CDECL)
dll$ = \sqlite3.dll
hDLL& = ImportDLL(dll$,_)
DBName$ = \TestDB3.db3
Print ---------
Error& = _sqlite3_open_v2(@Addr(DBName$),@Addr(hDB&),(&SQLITE_OPEN_READWRITE | &SQLITE_OPEN_CREATE),0)
Print @String$(_sqlite3_errmsg(hDB&),0)
Print ---------
SQLCmd$ = CREATE TABLE blobs(key TEXT PRIMARY KEY, value BLOB);
Error& = _sqlite3_exec(hDB&,@Addr(SQLCmd$),0,0,@Addr(Result&))
Print @String$(_sqlite3_errmsg(hDB&),0)
Print ---------
SQLCmd$ = INSERT INTO blobs(key, value) VALUES(?, ?);
Error& = _sqlite3_prepare_v2(hDB&,@Addr(SQLCmd$),-1,@Addr(Result&),0)
Print @String$(_sqlite3_errmsg(hDB&),0)
Print ---------
zKey$ = Bild
_sqlite3_bind_text(Result&,1,@Addr(zKey$),-1,&SQLITE_STATIC)
Print @String$(_sqlite3_errmsg(hDB&),0)
Print ---------
Datei$ = \Wasserlilien.jpg
Dim zBlob#,@FileSize(Datei$)
nBlob& = @BlockRead(Datei$,zBlob#,0,@FileSize(Datei$))
_sqlite3_bind_blob(Result&,2,zBlob#,@FileSize(Datei$),&SQLITE_TRANSIENT)
Print @String$(_sqlite3_errmsg(hDB&),0)
Dispose zBlob#
Print ---------
_sqlite3_step(Result&)
Print @String$(_sqlite3_errmsg(hDB&),0)
Print ---------
_sqlite3_finalize(Result&)
Print @String$(_sqlite3_errmsg(hDB&),0)
Print ---------
SQLCmd$ = SELECT value FROM blobs WHERE key = ?;
Error& = _sqlite3_prepare_v2(hDB&,@Addr(SQLCmd$),-1,@Addr(Result&),0)
Print @String$(_sqlite3_errmsg(hDB&),0)
Print ---------
zKey$ = Bild
_sqlite3_bind_text(Result&,1,@Addr(zKey$),-1,&SQLITE_STATIC)
Print @String$(_sqlite3_errmsg(hDB&),0)
Print ---------
_sqlite3_step(Result&)
Print @String$(_sqlite3_errmsg(hDB&),0)
Print ---------
pnBlob& = _sqlite3_column_bytes(Result&,0)
Datei$ = \Blob_Wasserlilien.jpg
Dim FBuf#,1024
String FBuf#,0 = Datei$ + @Chr$(0)
FHdl& = CreateFile(FBuf#,$40000000,0,0,$4,$80,0)
WriteFile(FHdl&,_sqlite3_column_blob(Result&,0),pnBlob&,@Addr(BWrite&),0)
CloseHandle(FHdl&)
Dispose FBuf#
Print ---------
_sqlite3_finalize(Result&)
Print @String$(_sqlite3_errmsg(hDB&),0)
Print ---------
Error& = _sqlite3_close(hDB&)
Print @String$(_sqlite3_errmsg(hDB&),0)
Print ---------
WaitInput
../../Function-References/XProfan/freedll/'>FreeDLL hDLL&
End
 
Viele Grüsse, Georg Hovenbitzer(Windows XP Pro, XProfan 11.2, Profan2Cpp 1.6a)
02/04/09  
 




Uwe
''Pascal''
Niemeier
Hi Georg!

The Idea start, me To fallen...
That the ImageList or bmp-data in Memory-Variables Although plainer, but since come quick a couple MB together (without Original-Images!).

the VB-example could there useful his...

iF
such one z.B. 48x48 JPG 60% ought to under 1 KB data need, means too base64-kodiert no trouble...


gives it there a boundary, what The Datenlänge concerns?

SeeYou
Pascal
 
02/04/09  
 




Uwe
''Pascal''
Niemeier
I again

from your example and the Code Andreas have I time quick this gebastelt:
CompileMarkSeparation
 $H windows.ph
 $H Functions_GDIPLUS.ph
 $H GDIP_Imageging.ph
 $I GDIP_Helper.inc
---Für Header:
CoInitialize(=External(ole32,CoInitialize,;
CoUninitialize(=External(ole32,CoUninitialize,;
CreateStreamOnHGlobal(=External(ole32,CreateStreamOnHGlobal,;
GetHGlobalFromStream(=External(ole32,GetHGlobalFromStream,;
def CoInitialize(1) !ole32,CoInitialize
def CoUninitialize(0) !ole32,CoUninitialize
def CreateStreamOnHGlobal(3) !ole32,CreateStreamOnHGlobal
def GetHGlobalFromStream(2) !ole32,GetHGlobalFromStream

Proc SaveJpgToMem---------------------------------------SaveJpgToMem

    Parameters Bitmap&,Quality&
    Declare encoderCLSID#,result&
    result& = 0
    Dim encoderCLSID#,16
    Declare encoderParameters#
    Declare wTemp$,encoder#
    wTemp$ = S2WS(~EncoderQuality)
    Dim encoder#,16
    IIDFromString(ADDR(wTemp$),encoder#)
    Dim encoderParameters#,32
    Long encoderParameters#,0 = 1
    MoveMemory(encoderParameters#+4,encoder#,16)
    Long encoderParameters#,20 = 1
    Long encoderParameters#,24 = ~EncoderParameterValueTypeLong
    Long encoderParameters#,28 = ADDR(Quality&)

    If GetEncoderCLSID(image/jpeg,encoderCLSID#)

        --Original: ~GdipSaveImageToFile(Bitmap&,ADDR(newFile$),encoderCLSID#,encoderParameters#)
        CoInitialize(0)--------------------------------------------------
        declare IStream&
        CreateStreamOnHGlobal(0,1,addr(IStream&))
        ~GdipSaveImageToStream(Bitmap&,IStream&,encoderCLSID#,encoderParameters#)
        declare Global&,Mem&,Size&
        GetHGlobalFromStream(IStream&,addr(Global&))
        Mem&=~GlobalLock(Global&)
        Size&=~GlobalSize(Global&)
        dim PicData#,Size&---------------PicData# global deklariert
        MoveMemory(PicData#,Mem&,Size&)--MoveMemory definiert in GDIP_Helper.inc
        ~GlobalUnlock(Global&)
        ~GlobalFree(Global&)
        CoUninitialize()-------------------------------------------------
        result& = 1

    Endif

    Dispose encoder#
    Dispose encoderParameters#
    Dispose encoderCLSID#
    Return result&
    EndProc-------------------------------------------------------------
    Declare gdiplusToken&,ImageObject&,ImageWidth&,ImageHeight&,GraphicObject&
    Declare hPic&
    Declare imgThumb&
    Declare lngImage&
    Declare hBitmap&
    Window 0,0-500,500
    gdiplusToken& = InitGDIPlus()
    hPic&=create(hPic,-1,C:1TestBild.jpg)-----------------------Pfad anpassen!
    ~GdipCreateBitmapFromHBITMAP(hPic&,0,addr(lngImage&))
    ~GdipGetImageThumbnail(lngImage&,120,120,addr(imgThumb&),0,0)
    ~GdipCreateHBITMAPFromBitmap(imgThumb&,addr(hBitmap&),0)--Drei Parameter!!
    DrawPic hBitmap&,50,50;0
    declare PicData#--wird vor Ort jeweils passend dimensioniert
    SaveJpgToMem(imgThumb&,75)
    -----------------------------Test
    assign #1,C:1TestTest.jpg
    openrw #1
    blockwrite #1,PicData#,0,sizeof(PicData#)
    close #1
    WaitInput
    DeleteObject hPic&
    DeleteObject hBitmap&
    ~GdipDisposeImage(imgThumb&)
    ~GdipDisposeImage(lngImage&)
    ExitGDIPlus(gdiplusToken&pan>
    End

After appeal of SaveJpgToMem  finds itself the complete code the new erstellten JPG in PicData#.
sure yet verbesserungsfähig,but so could one already what begin...

HTH
Pascal
 
02/04/09  
 




Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

18.770 Views

Themeninformationen



Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie