1. Graphics in Win32lib

I need to be able to display background images in my window, but as this is 
destined to be used by people other than myself, I want it to scale 
gracefully on other resolutions.

At the moment I just use loadbitmapfromfile and BLT it to the screen, but 
how would I have a single bitmap image, that I can output as a smaller size?

I know how to make a simple scaling algorithm if one does not already exist, 
but how would I get access to the 2d array that loadbitmapfromfile no doubt 
puts somewhere, and how would I save my altered array into a bitmap object?

...If that made sense, that is.
=====================================================
.______<-------------------\__
/ _____<--------------------__|===
||_    <-------------------/
\__| Mr Trick

new topic     » topic index » view message » categorize

2. Re: Graphics in Win32lib

--0-1966750244-1034226822=:71478


Try StretchBlt and SetStretchBltMode from GDI32.  These functions copy from one
DC to another but allow the destination rectangle to be either smaller or larger
the the source rectangle.  If so, Windows will scale the image accordingly.
Don Phillips

I need to be able to display background images in my window, but as this is 
destined to be used by people other than myself, I want it to scale 
gracefully on other resolutions.

At the moment I just use loadbitmapfromfile and BLT it to the screen, but 
how would I have a single bitmap image, that I can output as a smaller size?

I know how to make a simple scaling algorithm if one does not already exist, 
but how would I get access to the 2d array that loadbitmapfromfile no doubt 
puts somewhere, and how would I save my altered array into a bitmap object?

...If that made sense, that is.
=====================================================
.______<-------------------\__
/ _____<--------------------__|===
||_ <-------------------/
\__| Mr Trick







<P>Try StretchBlt and SetStretchBltMode from GDI32.&nbsp; These functions copy
from one DC to another but allow the destination rectangle to be either smaller
or larger the the source rectangle.&nbsp; If so, Windows will scale the image
accordingly.
<P>Don Phillips
<P>&nbsp;<B><I>mistertrik at hotmail.com</I></B> wrote:
<b><a href="http://news.yahoo.com/">Yahoo! News</a></b> - Today's headlines
--0-1966750244-1034226822=:71478--

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

3. Re: Graphics in Win32lib

GDI? What is that?


>From: Don Phillips <EuNexus at yahoo.com>
>Subject: Re: Graphics in Win32lib
>
>
>Try StretchBlt and SetStretchBltMode from GDI32.  These functions copy from 
>one DC to another but allow the destination rectangle to be either smaller 
>or larger the the source rectangle.  If so, Windows will scale the image 
>accordingly.
>Don Phillips
>
>I need to be able to display background images in my window, but as this is
>destined to be used by people other than myself, I want it to scale
>gracefully on other resolutions.
>
>At the moment I just use loadbitmapfromfile and BLT it to the screen, but
>how would I have a single bitmap image, that I can output as a smaller 
>size?
>
>I know how to make a simple scaling algorithm if one does not already 
>exist,
>but how would I get access to the 2d array that loadbitmapfromfile no doubt
>puts somewhere, and how would I save my altered array into a bitmap object?
>
>...If that made sense, that is.
>=====================================================
>.______<-------------------\__
>/ _____<--------------------__|===
>||_ <-------------------/
>\__| Mr Trick
>
>
><P>Try StretchBlt and SetStretchBltMode from GDI32.&nbsp; These functions 
>copy from one DC to another but allow the destination rectangle to be 
>either smaller or larger the the source rectangle.&nbsp; If so, Windows 
>will scale the image accordingly.
><P>Don Phillips
><P>&nbsp;<B><I>mistertrik at hotmail.com</I></B> wrote:
><b><a href="http://news.yahoo.com/">Yahoo! News</a></b> - Today's headlines
>
>
>




=====================================================
.______<-------------------\__
/ _____<--------------------__|===
||_    <-------------------/
\__| Mr Trick

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

4. Re: Graphics in Win32lib

GDI32 is a Windows .DLL.  StretchBlt and SetStretchBltMode are functions 
within it.  I'm not sure what GDI stands for, probably something like 
Graphics Device Interface?



mistertrik at hotmail.com wrote:

>
>
>> From: Don Phillips <EuNexus at yahoo.com>
>> Reply-To: EUforum at topica.com
>> To: EUforum <EUforum at topica.com>
>> Subject: Re: Graphics in Win32lib
>> Date: Wed, 9 Oct 2002 22:13:42 -0700 (PDT)
>>
>>
>> Try StretchBlt and SetStretchBltMode from GDI32.  These functions 
>> copy from one DC to another but allow the destination rectangle to be 
>> either smaller or larger the the source rectangle.  If so, Windows 
>> will scale the image accordingly.
>> Don Phillips
>>
>> I need to be able to display background images in my window, but as 
>> this is
>> destined to be used by people other than myself, I want it to scale
>> gracefully on other resolutions.
>>
>> At the moment I just use loadbitmapfromfile and BLT it to the screen, 
>> but
>> how would I have a single bitmap image, that I can output as a 
>> smaller size?
>>
>> I know how to make a simple scaling algorithm if one does not already 
>> exist,
>> but how would I get access to the 2d array that loadbitmapfromfile no 
>> doubt
>> puts somewhere, and how would I save my altered array into a bitmap 
>> object?
>>
>> ...If that made sense, that is.
>> =====================================================
>> .______<-------------------\__
>> / _____<--------------------__|===
>> ||_ <-------------------/
>> \__| Mr Trick
>>
>>
>> <P>Try StretchBlt and SetStretchBltMode from GDI32.&nbsp; These 
>> functions copy from one DC to another but allow the destination 
>> rectangle to be either smaller or larger the the source 
>> rectangle.&nbsp; If so, Windows will scale the image accordingly.
>> <P>Don Phillips
>> <P>&nbsp;<B><I>mistertrik at hotmail.com</I></B> wrote:
>> <b><a href="http://news.yahoo.com/">Yahoo! News</a></b> - Today's 
>> headlines
>>
>>
> =====================================================
> .______<-------------------\__
> / _____<--------------------__|===
> ||_    <-------------------/
> \__| Mr Trick
>
>
>
>

-- 
If today is the first day of the rest of your life, then what the hell
was yesterday?

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

5. Re: Graphics in Win32lib

Try my "Stretch Bitmap Demo" in Rec Usr Contrib.

    Martin

> GDI? What is that?
> 
> 
> >From: Don Phillips <EuNexus at yahoo.com>
> >Reply-To: EUforum at topica.com
> >To: EUforum <EUforum at topica.com>
> >Subject: Re: Graphics in Win32lib
> >Date: Wed, 9 Oct 2002 22:13:42 -0700 (PDT)
> >
> >
> >Try StretchBlt and SetStretchBltMode from GDI32.  These functions copy from 
> >one DC to another but allow the destination rectangle to be either smaller 
> >or larger the the source rectangle.  If so, Windows will scale the image 
> >accordingly.
> >Don Phillips
> >
> >I need to be able to display background images in my window, but as this is
> >destined to be used by people other than myself, I want it to scale
> >gracefully on other resolutions.
> >
> >At the moment I just use loadbitmapfromfile and BLT it to the screen, but
> >how would I have a single bitmap image, that I can output as a smaller 
> >size?
> >
> >I know how to make a simple scaling algorithm if one does not already 
> >exist,
> >but how would I get access to the 2d array that loadbitmapfromfile no doubt
> >puts somewhere, and how would I save my altered array into a bitmap object?
> >
> >...If that made sense, that is.
> >=====================================================
> >.______<-------------------\__
> >/ _____<--------------------__|===
> >||_ <-------------------/
> >\__| Mr Trick
> >
> >
> ><P>Try StretchBlt and SetStretchBltMode from GDI32.&nbsp; These functions 
> >copy from one DC to another but allow the destination rectangle to be 
> >either smaller or larger the the source rectangle.&nbsp; If so, Windows 
> >will scale the image accordingly.
> ><P>Don Phillips
> ><P>&nbsp;<B><I>mistertrik at hotmail.com</I></B> wrote:
> ><b><a href="http://news.yahoo.com/">Yahoo! News</a></b> - Today's headlines
> >
> >
> =====================================================
> .______<-------------------\__
> / _____<--------------------__|===
> ||_    <-------------------/
> \__| Mr Trick
> 
> 
> 
>

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

6. Re: Graphics in Win32lib

This is a multi-part message in MIME format.

------=_NextPart_000_1523_1b0b_102

Thanks Martin. There's a problem with it though, I think it's the fault of 
the win function rather than your code, because I found the same thing 
occurring in a contribution Windows Animation Effect (that used stretchblt 
as well).

My bitmap (in the .zip) has a section that goes from black to orange as a 
smooth graduation. When it is resized smaller, dark bands appear in the 
middle of the section. I found a similar thing with the turtle bitmap, 
although it had to be resized quite small before the effect was noticed. 
Does anyone know why this is, because such a glitch is not acceptable for my 
purposes? I'm running Win2k here if that helps.

Thanks
=====================================================
.______<-------------------\__
/ _____<--------------------__|===
||_    <-------------------/
\__| Mr Trick


>From: Martin Stachon <martin.stachon at worldonline.cz>
>Reply-To: EUforum at topica.com
>To: EUforum <EUforum at topica.com>
>Subject: Re: Graphics in Win32lib
>Date: Thu, 10 Oct 2002 18:03:55 +0200
>
>
>Try my "Stretch Bitmap Demo" in Rec Usr Contrib.
>
>     Martin
>
> > GDI? What is that?
> >
> >
> > >From: Don Phillips <EuNexus at yahoo.com>
> > >Reply-To: EUforum at topica.com
> > >To: EUforum <EUforum at topica.com>
> > >Subject: Re: Graphics in Win32lib
> > >Date: Wed, 9 Oct 2002 22:13:42 -0700 (PDT)
> > >
> > >
> > >Try StretchBlt and SetStretchBltMode from GDI32.  These functions copy 
>from
> > >one DC to another but allow the destination rectangle to be either 
>smaller
> > >or larger the the source rectangle.  If so, Windows will scale the 
>image
> > >accordingly.
> > >Don Phillips
> > >
> > >I need to be able to display background images in my window, but as 
>this is
> > >destined to be used by people other than myself, I want it to scale
> > >gracefully on other resolutions.
> > >
> > >At the moment I just use loadbitmapfromfile and BLT it to the screen, 
>but
> > >how would I have a single bitmap image, that I can output as a smaller
> > >size?
> > >
> > >I know how to make a simple scaling algorithm if one does not already
> > >exist,
> > >but how would I get access to the 2d array that loadbitmapfromfile no 
>doubt
> > >puts somewhere, and how would I save my altered array into a bitmap 
>object?
> > >
> > >...If that made sense, that is.
> > >=====================================================
> > >.______<-------------------\__
> > >/ _____<--------------------__|===
> > >||_ <-------------------/
> > >\__| Mr Trick
> > >
> > >
> > ><P>Try StretchBlt and SetStretchBltMode from GDI32.&nbsp; These 
>functions
> > >copy from one DC to another but allow the destination rectangle to be
> > >either smaller or larger the the source rectangle.&nbsp; If so, Windows
> > >will scale the image accordingly.
> > ><P>Don Phillips
> > ><P>&nbsp;<B><I>mistertrik at hotmail.com</I></B> wrote:
> > ><b><a href="http://news.yahoo.com/">Yahoo! News</a></b> - Today's 
>headlines
> > >
> > >
> > =====================================================
> > .______<-------------------\__
> > / _____<--------------------__|===
> > ||_    <-------------------/
> > \__| Mr Trick
> >
> >
>
>







------=_NextPart_000_1523_1b0b_102
Content-Type: application/x-zip-compressed; name="fireball.zip"

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

7. Re: Graphics in Win32lib

hi what is fire ball?
----- Original Message -----
From: <mistertrik at hotmail.com>
Subject: Re: Graphics in Win32lib


>
> Thanks Martin. There's a problem with it though, I think it's the fault of
> the win function rather than your code, because I found the same thing
> occurring in a contribution Windows Animation Effect (that used stretchblt
> as well).
>
> My bitmap (in the .zip) has a section that goes from black to orange as a
> smooth graduation. When it is resized smaller, dark bands appear in the
> middle of the section. I found a similar thing with the turtle bitmap,
> although it had to be resized quite small before the effect was noticed.
> Does anyone know why this is, because such a glitch is not acceptable for
my
> purposes? I'm running Win2k here if that helps.
>
> Thanks
> =====================================================
> .______<-------------------\__
> / _____<--------------------__|===
> ||_    <-------------------/
> \__| Mr Trick
>
>
> >From: Martin Stachon <martin.stachon at worldonline.cz>
> >Reply-To: EUforum at topica.com
> >To: EUforum <EUforum at topica.com>
> >Subject: Re: Graphics in Win32lib
> >Date: Thu, 10 Oct 2002 18:03:55 +0200
> >
> >
> >Try my "Stretch Bitmap Demo" in Rec Usr Contrib.
> >
> >     Martin
> >
> > > GDI? What is that?
> > >
> > >
> > > >From: Don Phillips <EuNexus at yahoo.com>
> > > >Reply-To: EUforum at topica.com
> > > >To: EUforum <EUforum at topica.com>
> > > >Subject: Re: Graphics in Win32lib
> > > >Date: Wed, 9 Oct 2002 22:13:42 -0700 (PDT)
> > > >
> > > >
> > > >Try StretchBlt and SetStretchBltMode from GDI32.  These functions
copy
> >from
> > > >one DC to another but allow the destination rectangle to be either
> >smaller
> > > >or larger the the source rectangle.  If so, Windows will scale the
> >image
> > > >accordingly.
> > > >Don Phillips
> > > >
> > > >I need to be able to display background images in my window, but as
> >this is
> > > >destined to be used by people other than myself, I want it to scale
> > > >gracefully on other resolutions.
> > > >
> > > >At the moment I just use loadbitmapfromfile and BLT it to the screen,
> >but
> > > >how would I have a single bitmap image, that I can output as a
smaller
> > > >size?
> > > >
> > > >I know how to make a simple scaling algorithm if one does not already
> > > >exist,
> > > >but how would I get access to the 2d array that loadbitmapfromfile no
> >doubt
> > > >puts somewhere, and how would I save my altered array into a bitmap
> >object?
> > > >
> > > >...If that made sense, that is.
> > > >=====================================================
> > > >.______<-------------------\__
> > > >/ _____<--------------------__|===
> > > >||_ <-------------------/
> > > >\__| Mr Trick
> > > >
> > > >
> > > ><P>Try StretchBlt and SetStretchBltMode from GDI32.&nbsp; These
> >functions
> > > >copy from one DC to another but allow the destination rectangle to be
> > > >either smaller or larger the the source rectangle.&nbsp; If so,
Windows
> > > >will scale the image accordingly.
> > > ><P>Don Phillips
> > > ><P>&nbsp;<B><I>mistertrik at hotmail.com</I></B> wrote:
> > > ><b><a href="http://news.yahoo.com/">Yahoo! News</a></b> - Today's
> >headlines
> > > >
> > > >
> > > =====================================================
> > > .______<-------------------\__
> > > / _____<--------------------__|===
> > > ||_    <-------------------/
> > > \__| Mr Trick
> > >
> > >
>
>
>

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

8. Re: Graphics in Win32lib

It's a zipped bitmap. Given that unzipped it's ~700kb, it was probably 
better zipped. It's an example of the sort of image my program has to 
display. Martin's stretch example mangles it horribly, so I thought it would 
well represent my problem. (if you're still confused, download his stretch 
example from the recent contribution lists, and try displaying fireball.bmp 
in it. You'll soon see what I mean)
=====================================================
.______<-------------------\__
/ _____<--------------------__|===
||_    <-------------------/
\__| Mr Trick


>From: aaron_mr_cooldude at sympatico.ca
>Subject: Re: Graphics in Win32lib
>Date: Fri, 11 Oct 2002 20:30:22 -0400
>
>
>hi what is fire ball?
>----- Original Message -----
>From: <mistertrik at hotmail.com>
>To: EUforum <EUforum at topica.com>
>Sent: Thursday, October 10, 2002 7:50 PM
>Subject: Re: Graphics in Win32lib
>
>
> > Thanks Martin. There's a problem with it though, I think it's the fault 
>of
> > the win function rather than your code, because I found the same thing
> > occurring in a contribution Windows Animation Effect (that used 
>stretchblt
> > as well).
> >
> > My bitmap (in the .zip) has a section that goes from black to orange as 
>a
> > smooth graduation. When it is resized smaller, dark bands appear in the
> > middle of the section. I found a similar thing with the turtle bitmap,
> > although it had to be resized quite small before the effect was noticed.
> > Does anyone know why this is, because such a glitch is not acceptable 
>for
>my
> > purposes? I'm running Win2k here if that helps.
> >
> > Thanks
> > =====================================================
> > .______<-------------------\__
> > / _____<--------------------__|===
> > ||_    <-------------------/
> > \__| Mr Trick
> >
> >
> > >From: Martin Stachon <martin.stachon at worldonline.cz>
> > >Reply-To: EUforum at topica.com
> > >To: EUforum <EUforum at topica.com>
> > >Subject: Re: Graphics in Win32lib
> > >Date: Thu, 10 Oct 2002 18:03:55 +0200
> > >
> > >
> > >Try my "Stretch Bitmap Demo" in Rec Usr Contrib.
> > >
> > >     Martin
> > >
> > > > GDI? What is that?
> > > >
> > > >
> > > > >From: Don Phillips <EuNexus at yahoo.com>
> > > > >Reply-To: EUforum at topica.com
> > > > >To: EUforum <EUforum at topica.com>
> > > > >Subject: Re: Graphics in Win32lib
> > > > >Date: Wed, 9 Oct 2002 22:13:42 -0700 (PDT)
> > > > >
> > > > >
> > > > >Try StretchBlt and SetStretchBltMode from GDI32.  These functions
>copy
> > >from
> > > > >one DC to another but allow the destination rectangle to be either
> > >smaller
> > > > >or larger the the source rectangle.  If so, Windows will scale the
> > >image
> > > > >accordingly.
> > > > >Don Phillips
> > > > >
> > > > >I need to be able to display background images in my window, but as
> > >this is
> > > > >destined to be used by people other than myself, I want it to scale
> > > > >gracefully on other resolutions.
> > > > >
> > > > >At the moment I just use loadbitmapfromfile and BLT it to the 
>screen,
> > >but
> > > > >how would I have a single bitmap image, that I can output as a
>smaller
> > > > >size?
> > > > >
> > > > >I know how to make a simple scaling algorithm if one does not 
>already
> > > > >exist,
> > > > >but how would I get access to the 2d array that loadbitmapfromfile 
>no
> > >doubt
> > > > >puts somewhere, and how would I save my altered array into a bitmap
> > >object?
> > > > >
> > > > >...If that made sense, that is.
> > > > >=====================================================
> > > > >.______<-------------------\__
> > > > >/ _____<--------------------__|===
> > > > >||_ <-------------------/
> > > > >\__| Mr Trick
> > > > >
> > > > >
<snip>

>
>

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

9. Re: Graphics in Win32lib

----- Original Message -----
From: <mistertrik at hotmail.com>

> When it is resized smaller, dark bands appear in the
> middle of the section.

Hi,

I have solution for you. You have to use SetStretchBltMode on destination dc
before painting your bitmap onto it with HALFTONE parameter.

add this code to Matrin's stretch.exw:

-- 1. Definitions:

global constant xSetStretchBltMode = registerw32Function (gdi32,
"SetStretchBltMode", {C_LONG, C_INT}, C_INT)
global constant  HALFTONE                     = 4


-- 2. In function stretchBlt () before calling xStretchBlt () insert this:

if w32Func (xSetStretchBltMode, {
        dstDC, HALFTONE
        }) = 0 then
        if message_box ("SetStretchBltMode failed", "", 0) then end if
    end if

-- copy area
    if not w32Func( xStretchBlt, {
...

Run it. Now your image is displayed very nice.

You'll have to be careful with this cause I think it doesn't work on all
versions of Windows operating system. I have actual experience with it. If I
remember correct it doesn't work on some Winnt version (and win9x?).

This mode works especially good if you shrink large image into very small
image.

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

10. Re: Graphics in Win32lib

Thank you, that worked fine.


>From: tone.skoda at gmx.net
>Subject: Re: Graphics in Win32lib
>
>
>----- Original Message -----
>From: <mistertrik at hotmail.com>
>
> > When it is resized smaller, dark bands appear in the
> > middle of the section.
>
>Hi,
>
>I have solution for you. You have to use SetStretchBltMode on destination 
>dc
>before painting your bitmap onto it with HALFTONE parameter.
>
>add this code to Matrin's stretch.exw:
>
>-- 1. Definitions:
>
>global constant xSetStretchBltMode = registerw32Function (gdi32,
>"SetStretchBltMode", {C_LONG, C_INT}, C_INT)
>global constant  HALFTONE                     = 4
>
>
>-- 2. In function stretchBlt () before calling xStretchBlt () insert this:
>
>if w32Func (xSetStretchBltMode, {
>         dstDC, HALFTONE
>         }) = 0 then
>         if message_box ("SetStretchBltMode failed", "", 0) then end if
>     end if
>
>-- copy area
>     if not w32Func( xStretchBlt, {
>...
>
>Run it. Now your image is displayed very nice.
>
>You'll have to be careful with this cause I think it doesn't work on all
>versions of Windows operating system. I have actual experience with it. If 
>I
>remember correct it doesn't work on some Winnt version (and win9x?).
>
>This mode works especially good if you shrink large image into very small
>image.
>
>
>




=====================================================
.______<-------------------\__
/ _____<--------------------__|===
||_    <-------------------/
\__| Mr Trick

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

Search



Quick Links

User menu

Not signed in.

Misc Menu