Question about dc.Draw

Hi, All:
     I have a question about drawing image on DC.
     I only find that we could draw image using dc.DrawBitmap(), and
if other format like png, jpeg, they have to be convert to bitmap.
     I wonder if there is a way to directly draw vector graph without
convert to bitmap?
     Thanks!

All DCs draw only bitmaps. PNG and JPG are disk image file types that
hold bitmap images in their own particular data formats.

When a DC has completed drawing a bitmap it is simple to save it to
any of the disk file types. For example:

    bmap.SaveFile( 'myFilename.png' )

Reading an image file to create a bitmap is just as easy:

    bmap = wx.Image( 'myFilename.png' ).ConvertToBitmap()

Since the filenames end with ".png" wx knows to read and write PNG
type files. You could substitute ".jpg", ".bmp", ".gif", etc.

Ray

···

On Feb 7, 3:30 am, zhengqing <zhengqing...@gmail.com> wrote:

Hi, All:
I have a question about drawing image on DC.
I only find that we could draw image using dc.DrawBitmap(), and
if other format like png, jpeg, they have to be convert to bitmap.
I wonder if there is a way to directly draw vector graph without
convert to bitmap?
Thanks!

Oops! You should read an image file this way:

    bmap = wx.Image( 'myFilename.png', wx.BITMAP_TYPE_ANY )

···

On Feb 7, 12:56 pm, Ray Pasco <pascor22...@gmail.com> wrote:

Since the filenames end with ".png" wx knows to read and write PNG
type files. You could substitute ".jpg", ".bmp", ".gif", etc.

Ray

zhengqing wrote:

     I have a question about drawing image on DC.
     I only find that we could draw image using dc.DrawBitmap(), and
if other format like png, jpeg, they have to be convert to bitmap.
     I wonder if there is a way to directly draw vector graph without
convert to bitmap?

PNG and JPEG are not vector graphics formats. They are bitmaps. The
only vector graphics formats you are likely to encounter are EPS and
SVG, neither of which has any native support in Windows.

The Windows APIs only understand BMP and (to a certain extent) JPEG. If
you hope to use the APIs to do drawing, it needs to be in one of those
formats.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

When I found out about SVG, it irked me that I couldn't download it in an HTML <img .../> tag. It's not strictly true that wx.DC can only draw bitmaps. It has all those methods like DrawLine, DrawLines, DrawArc... I'm going to try writing some functions next piece of spare time I get.

  Mel.

···

On 11-02-07 02:13 PM, Tim Roberts wrote:

zhengqing wrote:

      I have a question about drawing image on DC.
      I only find that we could draw image using dc.DrawBitmap(), and
if other format like png, jpeg, they have to be convert to bitmap.
      I wonder if there is a way to directly draw vector graph without
convert to bitmap?

PNG and JPEG are not vector graphics formats. They are bitmaps. The
only vector graphics formats you are likely to encounter are EPS and
SVG, neither of which has any native support in Windows.

Mel Wilson wrote:

PNG and JPEG are not vector graphics formats. They are bitmaps. The
only vector graphics formats you are likely to encounter are EPS and
SVG, neither of which has any native support in Windows.

When I found out about SVG, it irked me that I couldn't download it in
an HTML <img .../> tag.

Firefox can do that, but IE can't. Yet.

It's not strictly true that wx.DC can only draw bitmaps. It has all those methods like DrawLine, DrawLines, DrawArc... I'm going to try writing some functions next piece of spare time I get.

Of course you can draw vector graphics by hand, but the original poster
was confused about his terminology. I suspect he was not interested in
vector graphics at all.

···

On 11-02-07 02:13 PM, Tim Roberts wrote:

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Thank you all for your help.
It makes me understand more about the format of images.

···

On Feb 7, 11:43 am, Tim Roberts <t...@probo.com> wrote:

Mel Wilson wrote:
> On 11-02-07 02:13 PM, Tim Roberts wrote:

>> PNG and JPEG are not vector graphics formats. They are bitmaps. The
>> only vector graphics formats you are likely to encounter are EPS and
>> SVG, neither of which has any native support in Windows.
> When I found out about SVG, it irked me that I couldn't download it in
> an HTML <img .../> tag.

Firefox can do that, but IE can't. Yet.

> It's not strictly true that wx.DC can only draw bitmaps. It has all those methods like DrawLine, DrawLines, DrawArc... I'm going to try writing some functions next piece of spare time I get.

Of course you can draw vector graphics by hand, but the original poster
was confused about his terminology. I suspect he was not interested in
vector graphics at all.

--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

And the main purpose of the question is that how to increase the
quality of bitmaps when zoom in or zoom out the bitmap.
When I drawbitmap in a panel, if I change the size of the panel and
bitmap, the quality of the image will be really bad. I wonder if there
is a way to increase the quality.

I just simply use the Rescale function to change the size of the
image, and the convert it to bitmap. Is there a better way to do that
for quality purpose?
Thanks!

···

On Feb 7, 8:07 pm, zhengqing <zhengqing...@gmail.com> wrote:

Thank you all for your help.
It makes me understand more about the format of images.

On Feb 7, 11:43 am, Tim Roberts <t...@probo.com> wrote:

> Mel Wilson wrote:
> > On 11-02-07 02:13 PM, Tim Roberts wrote:

> >> PNG and JPEG are not vector graphics formats. They are bitmaps. The
> >> only vector graphics formats you are likely to encounter are EPS and
> >> SVG, neither of which has any native support in Windows.
> > When I found out about SVG, it irked me that I couldn't download it in
> > an HTML <img .../> tag.

> Firefox can do that, but IE can't. Yet.

> > It's not strictly true that wx.DC can only draw bitmaps. It has all those methods like DrawLine, DrawLines, DrawArc... I'm going to try writing some functions next piece of spare time I get.

> Of course you can draw vector graphics by hand, but the original poster
> was confused about his terminology. I suspect he was not interested in
> vector graphics at all.

> --
> Tim Roberts, t...@probo.com
> Providenza & Boekelheide, Inc.

It will never get better than your original image. It can get worse; one trap would be to scale down your original image for a smaller window, then scale-up the scaled-down image when the window expands. (I don't know if you're doing anything like this.) Best to always work from the original.

  Mel.

···

On 11-02-07 11:14 PM, zhengqing wrote:

And the main purpose of the question is that how to increase the
quality of bitmaps when zoom in or zoom out the bitmap.
When I drawbitmap in a panel, if I change the size of the panel and
bitmap, the quality of the image will be really bad. I wonder if there
is a way to increase the quality.

I just simply use the Rescale function to change the size of the
image, and the convert it to bitmap. Is there a better way to do that
for quality purpose?
Thanks!

wx.BITMAP_TYPE_ANY is the default value for that parameter so it is okay to leave it out.

···

On 2/7/11 10:01 AM, Ray Pasco wrote:

On Feb 7, 12:56 pm, Ray Pasco<pascor22...@gmail.com> wrote:

Since the filenames end with ".png" wx knows to read and write PNG
type files. You could substitute ".jpg", ".bmp", ".gif", etc.

Ray

Oops! You should read an image file this way:

     bmap = wx.Image( 'myFilename.png', wx.BITMAP_TYPE_ANY )

--
Robin Dunn
Software Craftsman