1. Bitmap clearing

If I have a win32lib pixmap, what is the quickest/easiest way to clear all of it
to a given background color?
=======================
Patrick Barnes
Information Systems Group
201 Elizabeth St, Sydney
Patrick.Barnes at transgrid.com.au
Ext: 91-3583
Ph:(02) 9284-3583
Mob: 0410 751 044


***********************************************************************




***********************************************************************

new topic     » topic index » view message » categorize

2. Re: Bitmap clearing

> If I have a win32lib pixmap, what is the quickest/easiest way to clear all of
> it to a given background color?

... simply:
  setPenColor(yourPix, yourColor)
  drawRectangle(yourPix, 1, 0, 0 ,x_size, y_size)

new topic     » goto parent     » topic index » view message » categorize

3. Re: Bitmap clearing

Use the gdi function called patblt().
It is the fastest method to me and many more will agree.

Jordah
----- Original Message -----
From: <Patrick.Barnes at transgrid.com.au>
To: "EUforum" <EUforum at topica.com>
Subject: Bitmap clearing


>
> If I have a win32lib pixmap, what is the quickest/easiest way to clear all
of it to a given background color?
> =======================
> Patrick Barnes
> Information Systems Group
> 201 Elizabeth St, Sydney
> Patrick.Barnes at transgrid.com.au
> Ext: 91-3583
> Ph:(02) 9284-3583
> Mob: 0410 751 044
>
>
> ***********************************************************************
>
>
> ***********************************************************************
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>


---

new topic     » goto parent     » topic index » view message » categorize

4. Re: Bitmap clearing

Hi i have just confirmed with some research that Patblt is faster than
drawrectangle. Also, another method i found was having a memory bitmap. that
u can bitblt on your destDC

Jordah.
----- Original Message -----
From: <Patrick.Barnes at transgrid.com.au>
To: "EUforum" <EUforum at topica.com>
Subject: RE: Bitmap clearing


>
> Oh ok... if that's fast enough, then no problem... I just thought there
might be a faster way to do it.
>
> And what's the significance of a bitmap having a parent? I know it doesnt
*need* one.
>
> -----Original Message-----
> From: Wolf [mailto:wolfritz at KING.IGS.NET]
> Sent: Friday, 24 January 2003 10:36
> To: EUforum
> Subject: Re: Bitmap clearing
>
>
> > If I have a win32lib pixmap, what is the quickest/easiest way to clear
all of it to a given background color?
>
> ... simply:
>   setPenColor(yourPix, yourColor)
>   drawRectangle(yourPix, 1, 0, 0 ,x_size, y_size)
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>
> ***********************************************************************
>
>
> ***********************************************************************
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>


---

new topic     » goto parent     » topic index » view message » categorize

5. Re: Bitmap clearing

In win32lib, The pixmap(memory bitmap) requires a parent mainly for GDI
resource management. It makes the tracking of resources easier thus making
it faster to clean up

Jordah
----- Original Message -----
From: <Patrick.Barnes at transgrid.com.au>
To: "EUforum" <EUforum at topica.com>
Subject: RE: Bitmap clearing


>
> Oh ok... if that's fast enough, then no problem... I just thought there
might be a faster way to do it.
>
> And what's the significance of a bitmap having a parent? I know it doesnt
*need* one.
>
> -----Original Message-----
> From: Wolf [mailto:wolfritz at KING.IGS.NET]
> Sent: Friday, 24 January 2003 10:36
> To: EUforum
> Subject: Re: Bitmap clearing
>
>
> > If I have a win32lib pixmap, what is the quickest/easiest way to clear
all of it to a given background color?
>
> ... simply:
>   setPenColor(yourPix, yourColor)
>   drawRectangle(yourPix, 1, 0, 0 ,x_size, y_size)
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>
> ***********************************************************************
>
>
> ***********************************************************************
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>


---

new topic     » goto parent     » topic index » view message » categorize

6. Re: Bitmap clearing

Could u please tell me what u want to do? and i'll write u an include file
for those specific routines u need.

U will probably get the include file some time sartuday or sunday. i work
during the weekend. so even monday at latest.

Jordah. I'll try to comment the code well

----- Original Message -----
From: <Patrick.Barnes at transgrid.com.au>
To: "EUforum" <EUforum at topica.com>
Subject: RE: Bitmap clearing


>
> Do the Blt procedures work at ALL to pixmap objects?
>
> How would I copy an image to part of a pixmap object?
>
> -----Original Message-----
> From: Barnes Patrick
> Sent: Friday, 24 January 2003 13:05
> To: EUforum
> Subject: RE: Bitmap clearing
>
>
> Ok... well what I'm doing is...
>
> I have an array of pixmaps, all 1024x768 in size.
> There is a selection of graphics to be drawn to it, and I want to use
stretchBLT to put the images onto the pixmap (This not working - stretchBLT
doesn't like it).
> Text is just put on with wPuts.
> Then, one of those pixmaps is stretchBLT'd out to the window, at whatever
size the window is.
>
>
> -----Original Message-----
> From: jordah at btopenworld.com [mailto:jordah at btopenworld.com]
> Sent: Friday, 24 January 2003 12:46
> To: EUforum
> Subject: Re: Bitmap clearing
>
>
> In win32lib, The pixmap(memory bitmap) requires a parent mainly for GDI
> resource management. It makes the tracking of resources easier thus making
> it faster to clean up
>
> Jordah
> ----- Original Message -----
> From: <Patrick.Barnes at transgrid.com.au>
> To: "EUforum" <EUforum at topica.com>
> Sent: Friday, January 24, 2003 12:03 AM
> Subject: RE: Bitmap clearing
>
>
> > Oh ok... if that's fast enough, then no problem... I just thought there
> might be a faster way to do it.
> >
> > And what's the significance of a bitmap having a parent? I know it
doesnt
> *need* one.
> >
> > -----Original Message-----
> > From: Wolf [mailto:wolfritz at KING.IGS.NET]
> > Sent: Friday, 24 January 2003 10:36
> > To: EUforum
> > Subject: Re: Bitmap clearing
> >
> >
> > > If I have a win32lib pixmap, what is the quickest/easiest way to clear
> all of it to a given background color?
> >
> > ... simply:
> >   setPenColor(yourPix, yourColor)
> >   drawRectangle(yourPix, 1, 0, 0 ,x_size, y_size)
> >
> >
> > TOPICA - Start your own email discussion group. FREE!
> >
> >
> > ***********************************************************************
> >
> >
> > ***********************************************************************
> >
> >
> > TOPICA - Start your own email discussion group. FREE!
> >
>
> ---
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>
> ***********************************************************************
>
>
> ***********************************************************************
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>
> ***********************************************************************
>
>
> ***********************************************************************
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>


---

new topic     » goto parent     » topic index » view message » categorize

7. Re: Bitmap clearing

On Fri, 24 Jan 2003 15:31:49 +1100, Patrick.Barnes at transgrid.com.au
wrote:

I know this is evidently similar to what you have, but I have not
experienced any problems with this version, bitmap, or printer:

procedure stretchBlt( atom dst, integer dstX, integer dstY,=20
atom src, integer srcX, integer srcY,=20
integer destWide, integer destHigh,
integer srcWide, integer srcHigh, integer rop )=20
atom srcDC, dstDC
	-- get the DCs
	srcDC =3D getDC( src )
	dstDC =3D getDC( dst )
	-- copy area
	if not w32Func( xStretchBlt, {dstDC, dstX, dstY, destWide,
destHigh, srcDC,=20
								  srcX, srcY,
								  srcWide, srcHigh, rop} ) then=20
		warnErr( "stretchBlt:StretchBlt failed." )=20
	end if
	-- release the DCs   =20
	releaseDC( dst )=20
	releaseDC( src )
end procedure

HTH,

Pete

new topic     » goto parent     » topic index » view message » categorize

8. Re: Bitmap clearing

----- Original Message -----
From: <Patrick.Barnes at transgrid.com.au>
To: "EUforum" <EUforum at topica.com>
Subject: RE: Bitmap clearing


>
> Lifesaver!
>
> Routine 1:
>
> * Given a bitmap - from loadBitmapFromFile
> * Copies it to a specified Pixmap control
> * Given the position on the Pixmap control
> * Given the size of the bitmap on the pixmap control (ie can be
> 'stretched')
>
> Routine 2:
>
> * Given a pixmap control
> * Copies it to the screen
> * Given the position on the screen
> * Given the size of the pixmap control on the screen (ie can be
> 'stretched')


Screen / Pixmap, i'll do it for screen, just wanted to confirm.
>
> If you could do them, or even explain a little more clearly what needs to
> be done,
> I will be VERY grateful.
>
> ==============================================
>  _______<-------------------\__
> /  _____<--------------------__|===
> | |_    <-------------------/
> \__| Patrick Barnes
>
>
> -----Original Message-----
> From: jordah at btopenworld.com [mailto:jordah at btopenworld.com]
> Sent: Friday, 24 January 2003 15:19
> To: EUforum
> Subject: Re: Bitmap clearing
>
>
> Could u please tell me what u want to do? and i'll write u an include file
> for those specific routines u need.
>
> U will probably get the include file some time sartuday or sunday. i work
> during the weekend. so even monday at latest.
>
> Jordah. I'll try to comment the code well
>
> ----- Original Message -----
> From: <Patrick.Barnes at transgrid.com.au>
> To: "EUforum" <EUforum at topica.com>
> Sent: Friday, January 24, 2003 3:12 AM
> Subject: RE: Bitmap clearing
>
>
> > Do the Blt procedures work at ALL to pixmap objects?
> >
> > How would I copy an image to part of a pixmap object?
> >
> > -----Original Message-----
> > From: Barnes Patrick
> > Sent: Friday, 24 January 2003 13:05
> > To: EUforum
> > Subject: RE: Bitmap clearing
> >
> >
> > Ok... well what I'm doing is...
> >
> > I have an array of pixmaps, all 1024x768 in size.
> > There is a selection of graphics to be drawn to it, and I want to use
> stretchBLT to put the images onto the pixmap (This not working -
> stretchBLT
> doesn't like it).
> > Text is just put on with wPuts.
> > Then, one of those pixmaps is stretchBLT'd out to the window, at
> whatever
> size the window is.
> >
> >
> > -----Original Message-----
> > From: jordah at btopenworld.com [mailto:jordah at btopenworld.com]
> > Sent: Friday, 24 January 2003 12:46
> > To: EUforum
> > Subject: Re: Bitmap clearing
> >
> >
> > In win32lib, The pixmap(memory bitmap) requires a parent mainly for GDI
> > resource management. It makes the tracking of resources easier thus
> making
> > it faster to clean up
> >
> > Jordah
> > ----- Original Message -----
> > From: <Patrick.Barnes at transgrid.com.au>
> > To: "EUforum" <EUforum at topica.com>
> > Sent: Friday, January 24, 2003 12:03 AM
> > Subject: RE: Bitmap clearing
> >
> >
> > > Oh ok... if that's fast enough, then no problem... I just thought
> there
> > might be a faster way to do it.
> > >
> > > And what's the significance of a bitmap having a parent? I know it
> doesnt
> > *need* one.
> > >
> > > -----Original Message-----
> > > From: Wolf [mailto:wolfritz at KING.IGS.NET]
> > > Sent: Friday, 24 January 2003 10:36
> > > To: EUforum
> > > Subject: Re: Bitmap clearing
> > >
> > >
> > > > If I have a win32lib pixmap, what is the quickest/easiest way to
> clear
> > all of it to a given background color?
> > >
<snip>

>
>

---

new topic     » goto parent     » topic index » view message » categorize

9. Re: Bitmap clearing

Hi Patrick,

    I alittle bit under-estimated win32lib. It does alot of work for the
end-user. Its getDC has a very kewl construct. also, i have attached
BlankPixmap() which is a faster way to blank a pixmap.

Try this demo in  the win32lib directory because it requires mail.bmp

Hope this helps.
Jordah.

---------------------------------------------------------
--File   : Demo For Patrick
--Version:
--Date   :
--Author : Jordah Ferguson
---------------------------------------------------------

include win32lib.ew
-------------------------------------------

constant
  MainWindow = create(Window,"Demo for
Patrick",0,Default,Default,600,400,0),
  Pixmap1    = create(Pixmap,"",0,0,0,300,300,0),
  zPatBlt    =
registerw32Function(gdi32,"PatBlt",{C_LONG,C_LONG,C_INT,C_INT,C_INT,C_INT},C
_INT),
  -------------------------------------------
  Bitmap1    = loadBitmapFromFile(current_dir()&"\\mail.bmp")

-------------------------------------------
procedure PatBlt(atom hdc,atom x,atom y,atom cx,atom cy,atom rop)
-------------------------------------------
   if not w32Func(zPatBlt,{hdc,x,y,cy,cy,rop}) then
      warnErr("PatBlt Failed")
   end if
end procedure

-------------------------------------------
global procedure stretchBlt( atom dst, integer dstX, integer dstY,
      atom src, integer srcX, integer srcY,
      integer destWide, integer destHigh,
      integer srcWide, integer srcHigh,
      integer rop )
-------------------------------------------
    atom srcDC, dstDC
    srcDC = getDC( src )
    dstDC = getDC( dst )
    if not w32Func( xStretchBlt, {
      dstDC, dstX, dstY,
      destWide, destHigh,
      srcDC,
      srcX, srcY,
      srcWide, srcHigh,
      rop} ) then
      warnErr( "stretchBlt:StretchBlt failed." )
    end if
    releaseDC( dst )
    releaseDC( src )
end procedure

-------------------------------------------
procedure BlankPixmap(integer Pixmap,atom BkColor)
-------------------------------------------
   atom hdc,brush,oldbrush
   sequence rect
   rect = getRect(Pixmap)
   hdc = getDC(Pixmap) -- This already performs selectobject()
   brush = w32Func(xCreateSolidBrush,{BkColor})
   oldbrush = w32Func(xSelectObject,{hdc,brush})
   PatBlt(hdc,rect[1],rect[2],rect[3],rect[4],#00F00021)
   oldbrush = w32Func(xSelectObject,{hdc,oldbrush})
   oldbrush = w32Func(xDeleteObject,{brush})
   releaseDC(hdc)
end procedure


-------------------------------------------
procedure DrawToPixmap(integer Pix,atom hBmp,atom px,atom py,atom bitcx,atom
bitcy)
-------------------------------------------
   sequence rect
   rect = getRect(hBmp)
   stretchBlt(Pix,px,py,hBmp,0,0,bitcx,bitcy,rect[3],rect[4],SRCCOPY)
end procedure

-------------------------------------------
procedure DrawToScreen(integer dest,integer Pix,atom x,atom y,atom cx,atom
cy)
-------------------------------------------
   sequence rect
   rect = getRect(Pix)
   stretchBlt(dest,x,y,Pix,0,0,cx,cy,rect[3],rect[4],SRCCOPY)
end procedure

-------------------------------------------
procedure onPaint_Proc(integer id,integer event,sequence params)
-------------------------------------------
   sequence rect,rec,re
   re   = getClientRect(MainWindow)
   rect = getRect(Pixmap1)
   rec  = getRect(Bitmap1)
   BlankPixmap(Pixmap1,White)

DrawToPixmap(Pixmap1,Bitmap1,floor((rect[3]-rec[3])/2)-40,floor((rect[4]-rec
[4])/2)-40,rec[3]+40,rec[4]+40)
   DrawToScreen(MainWindow,Pixmap1,re[1],re[2],re[3],re[4])
end procedure
setHandler(MainWindow,w32HPaint,routine_id("onPaint_Proc"))

-------------------------------------------
procedure onResize_Proc(integer id,integer event,sequence params)
-------------------------------------------
   DrawToScreen(MainWindow,Pixmap1,0,0,params[2],params[3])
end procedure
setHandler(MainWindow,w32HResize,routine_id("onResize_Proc"))


-------------------------------------------
WinMain(MainWindow,Normal)



---

new topic     » goto parent     » topic index » view message » categorize

10. Re: Bitmap clearing

hi Patrick,
    Oops, that's my mistake sorry about that. My routines were a bit doggy
too. I hope that didn't give you much of a head-ache. "Smallest and easiest
bugs to fix, are the hardest to find" Sir LoJiK 2002

Jordah
----- Original Message -----
From: <Patrick.Barnes at transgrid.com.au>
To: "EUforum" <EUforum at topica.com>
Subject: RE: Bitmap clearing


>
> Hey Jordah...
> I found an error in your PatBLT procedure... I didn't notice until now,
because some of the pixmap wasn't clearing correctly, and I couldn't figure
out why:
>
> >-------------------------------------------
> >procedure PatBlt(atom hdc,atom x,atom y,atom cx,atom cy,atom rop)
> >-------------------------------------------
> >   if not w32Func(zPatBlt,{hdc,x,y,cy,cy,rop}) then
> >      warnErr("PatBlt Failed")      \-------perhaps that should be cx?
> >   end if
> >end procedure
>
> Very frustrating, I tore my program almost to pieces looking for the bug,
and it was your fault all along! :oP
>
> Hopefully you don't have that same error sitting somewhere.
>
> Thanks for the demo. VERY useful.
>
> -Pat
>
> -----Original Message-----
> From: jordah at btopenworld.com [mailto:jordah at btopenworld.com]
> Sent: Saturday, 25 January 2003 15:49
> To: EUforum
> Subject: Re: Bitmap clearing
>
>
> Hi Patrick,
>
>     I alittle bit under-estimated win32lib. It does alot of work for the
> end-user. Its getDC has a very kewl construct. also, i have attached
> BlankPixmap() which is a faster way to blank a pixmap.
>
> Try this demo in  the win32lib directory because it requires mail.bmp
>
> Hope this helps.
> Jordah.
>
> ---------------------------------------------------------
> --File   : Demo For Patrick
> --Version:
> --Date   :
> --Author : Jordah Ferguson
> ---------------------------------------------------------
>
> include win32lib.ew
> -------------------------------------------
>
> constant
>   MainWindow = create(Window,"Demo for
> Patrick",0,Default,Default,600,400,0),
>   Pixmap1    = create(Pixmap,"",0,0,0,300,300,0),
>   zPatBlt    =
>
registerw32Function(gdi32,"PatBlt",{C_LONG,C_LONG,C_INT,C_INT,C_INT,C_INT},C
> _INT),
>   -------------------------------------------
>   Bitmap1    = loadBitmapFromFile(current_dir()&"\\mail.bmp")
>
> -------------------------------------------
> procedure PatBlt(atom hdc,atom x,atom y,atom cx,atom cy,atom rop)
> -------------------------------------------
>    if not w32Func(zPatBlt,{hdc,x,y,cy,cy,rop}) then
>       warnErr("PatBlt Failed")
>    end if
> end procedure
>
> -------------------------------------------
> global procedure stretchBlt( atom dst, integer dstX, integer dstY,
>       atom src, integer srcX, integer srcY,
>       integer destWide, integer destHigh,
>       integer srcWide, integer srcHigh,
>       integer rop )
> -------------------------------------------
>     atom srcDC, dstDC
>     srcDC = getDC( src )
>     dstDC = getDC( dst )
>     if not w32Func( xStretchBlt, {
>       dstDC, dstX, dstY,
>       destWide, destHigh,
>       srcDC,
>       srcX, srcY,
>       srcWide, srcHigh,
>       rop} ) then
>       warnErr( "stretchBlt:StretchBlt failed." )
>     end if
>     releaseDC( dst )
>     releaseDC( src )
> end procedure
>
> -------------------------------------------
> procedure BlankPixmap(integer Pixmap,atom BkColor)
> -------------------------------------------
>    atom hdc,brush,oldbrush
>    sequence rect
>    rect = getRect(Pixmap)
>    hdc = getDC(Pixmap) -- This already performs selectobject()
>    brush = w32Func(xCreateSolidBrush,{BkColor})
>    oldbrush = w32Func(xSelectObject,{hdc,brush})
>    PatBlt(hdc,rect[1],rect[2],rect[3],rect[4],#00F00021)
>    oldbrush = w32Func(xSelectObject,{hdc,oldbrush})
>    oldbrush = w32Func(xDeleteObject,{brush})
>    releaseDC(hdc)
> end procedure
>
>
> -------------------------------------------
> procedure DrawToPixmap(integer Pix,atom hBmp,atom px,atom py,atom
bitcx,atom
> bitcy)
> -------------------------------------------
>    sequence rect
>    rect = getRect(hBmp)
>    stretchBlt(Pix,px,py,hBmp,0,0,bitcx,bitcy,rect[3],rect[4],SRCCOPY)
> end procedure
>
> -------------------------------------------
> procedure DrawToScreen(integer dest,integer Pix,atom x,atom y,atom cx,atom
> cy)
> -------------------------------------------
>    sequence rect
>    rect = getRect(Pix)
>    stretchBlt(dest,x,y,Pix,0,0,cx,cy,rect[3],rect[4],SRCCOPY)
> end procedure
>
> -------------------------------------------
> procedure onPaint_Proc(integer id,integer event,sequence params)
> -------------------------------------------
>    sequence rect,rec,re
>    re   = getClientRect(MainWindow)
>    rect = getRect(Pixmap1)
>    rec  = getRect(Bitmap1)
>    BlankPixmap(Pixmap1,White)
>
>
DrawToPixmap(Pixmap1,Bitmap1,floor((rect[3]-rec[3])/2)-40,floor((rect[4]-rec
> [4])/2)-40,rec[3]+40,rec[4]+40)
>    DrawToScreen(MainWindow,Pixmap1,re[1],re[2],re[3],re[4])
> end procedure
> setHandler(MainWindow,w32HPaint,routine_id("onPaint_Proc"))
>
> -------------------------------------------
> procedure onResize_Proc(integer id,integer event,sequence params)
> -------------------------------------------
>    DrawToScreen(MainWindow,Pixmap1,0,0,params[2],params[3])
> end procedure
> setHandler(MainWindow,w32HResize,routine_id("onResize_Proc"))
>
>
> -------------------------------------------
> WinMain(MainWindow,Normal)
>
>
> ---
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>
> ***********************************************************************
>
>
> ***********************************************************************
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>


---

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu