Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prepare "off-screen" bitmap information
#1
I am using systematically "OnScreenDisplay" to prepare and display on screen bitmap information.
I am aware of topic :
auto clip of desktop image
with which this information may be stored in a bitmapfile for later use.

I wonder whether there exists a routine to prepare this bitfile information off-line (ie. not necessarily displayed
on screen) and store in a bitmapfile for later use.

Many thanks in advance for any advice.
#2
What is "to prepare this bitfile information"? Is it about screen capturing?
#3
More specifically : I want to prepare a bitmap file, using ascii text, store it to clipboard and then paste it in an adobe acrobat file, action similar to inserting a stamp.
#4
Like this?

Macro Macro964
Code:
Copy      Help
BSTR b="Text"
__MemBmp m.Create(1000 100)
RECT r; SetRect &r 0 0 1000 100
DrawTextW m.dc b b.len &r 0
if(OpenClipboard(_hwndqm)) EmptyClipboard; SetClipboardData(CF_BITMAP m.Detach); CloseClipboard
#5
Thank you very much. Perfect!
#6
Dear Gintaras, could you please advise on the way to enclose to be stored in clipboard in a rectangle? Many thanks.
#7
Macro Macro965
Code:
Copy      Help
BSTR b="Text"

;create big memory DC
__MemBmp m.Create(1000 100)

;set font
__Font font.Create("Verdana" 14 2)
SelectObject m.dc font

;calculate text rectangle
RECT r; DrawTextW m.dc b b.len &r DT_CALCRECT|DT_EXPANDTABS|DT_NOPREFIX

;draw background and rectangle
OffsetRect &r 4 2
InflateRect &r 4 2
__GdiHandle brush=CreateSolidBrush(0xC0FFFF); SelectObject m.dc brush
__GdiHandle pen=CreatePen(0 2 0xff0000); SelectObject m.dc pen
Rectangle m.dc 1 1 r.right r.bottom

;draw text
SetBkMode m.dc TRANSPARENT
SetTextColor m.dc 0xff0000
InflateRect &r -4 -2
DrawTextW m.dc b b.len &r DT_EXPANDTABS|DT_NOPREFIX

;copy the rectangle to another memory DC (crop)
InflateRect &r 4 2
__MemBmp m2.Create(r.right r.bottom m.dc)

;bitmap to clipboard
if(OpenClipboard(_hwndqm)) EmptyClipboard; SetClipboardData(CF_BITMAP m2.Detach); CloseClipboard
#8
Thank you again for a perfect dynamic pdf stamp!
#9
Dear Gintaras, I would appreciate it if you could extend your instructions regarding the procedure to add a small icon (.ico file) to this off-screen bitmap information. Many thanks in advance.
#10
Use Windows API function DrawIconEx.
GetFileIcon - DrawIconEx - DestroyIcon.
#11
Is there a way to save directly to a file without using clipboard?

Currently I have this

Macro Macro4
Code:
Copy      Help
str ext="jpg"
str fname="test"
str infolder="$desktop$"
str sFile=F"{infolder}\{fname}.{ext}"


BSTR b="Text"

;create big memory DC
__MemBmp m.Create(1000 100)

;set font
__Font font.Create("Verdana" 14 2)
SelectObject m.dc font

;calculate text rectangle
RECT r; DrawTextW m.dc b b.len &r DT_CALCRECT|DT_EXPANDTABS|DT_NOPREFIX

;draw background and rectangle
OffsetRect &r 4 2
InflateRect &r 4 2
__GdiHandle brush=CreateSolidBrush(0xC0FFFF); SelectObject m.dc brush
__GdiHandle pen=CreatePen(0 2 0xff0000); SelectObject m.dc pen
Rectangle m.dc 1 1 r.right r.bottom

;draw text
SetBkMode m.dc TRANSPARENT
SetTextColor m.dc 0xff0000
InflateRect &r -4 -2
DrawTextW m.dc b b.len &r DT_EXPANDTABS|DT_NOPREFIX

;copy the rectangle to another memory DC (crop)
InflateRect &r 4 2
__MemBmp m2.Create(r.right r.bottom m.dc)

;bitmap to clipboard
if(OpenClipboard(_hwndqm))
,EmptyClipboard
,SetClipboardData(CF_BITMAP m2.Detach)
,;CloseClipboard
,_i=GetClipboardData(CF_BITMAP)
,__GdiHandle hb; if(_i) hb=CopyImage(_i 0 0 0 LR_CREATEDIBSECTION)
,CloseClipboard
,if(_i=0) end "no bitmap in clipboard"
,
,;save as jpg
,#compile "__Gdip"
,
,GdipBitmap im
,if(!im.FromHBITMAP(hb)) end "error"
,if(!im.Save(sFile)) end "error"

It is slightly modified with code from another example.
It works, but I do not know if code is "correct".
But would like to know if it is possible without using clipboard (save directly to file).
#12
How about this:

Macro Macro47
Code:
Copy      Help
str ext="jpg"
str fname="Test"
str infolder="$desktop$"
str sFile=F"{infolder}\{fname}.{ext}"

BSTR b="Test"

;create big memory DC
__MemBmp m.Create(1000 100)

;set font
__Font font.Create("Verdana" 14 2)
SelectObject m.dc font

;calculate text rectangle
RECT r; DrawTextW m.dc b b.len &r DT_CALCRECT|DT_EXPANDTABS|DT_NOPREFIX

;draw background and rectangle
OffsetRect &r 4 2
InflateRect &r 4 2
__GdiHandle brush=CreateSolidBrush(0xC0FFFF); SelectObject m.dc brush
__GdiHandle pen=CreatePen(0 2 0xff0000); SelectObject m.dc pen
Rectangle m.dc 1 1 r.right r.bottom

;draw text
SetBkMode m.dc TRANSPARENT
SetTextColor m.dc 0xff0000
InflateRect &r -4 -2
DrawTextW m.dc b b.len &r DT_EXPANDTABS|DT_NOPREFIX

;copy the rectangle to another memory DC (crop)
InflateRect &r 4 2
__MemBmp m2.Create(r.right r.bottom m.dc)

;save as jpg
#compile "__Gdip"
__GdiHandle hb=CopyImage(m2.Detach 0 0 0 LR_CREATEDIBSECTION)
GdipBitmap im
if(!im.FromHBITMAP(hb)) end "error"
if(!im.Save(sFile)) end "error"
#13
@TeddyBear
Yes that's it!
Thank you!


Forum Jump:


Users browsing this thread: 3 Guest(s)