Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GDI+ questions

50 views
Skip to first unread message

Albert P.

unread,
Oct 5, 2009, 12:09:09 PM10/5/09
to
Hi,

I'm using GDI+ api to draw a day time planning into a picture, it's great,
very fast and import of png with transparency is very neat.

I have one problem, 90% of the time, I don't need to redraw all the picture,
the background is the same and only the items on it changes.

I would like to make a copy of this background and when I need it redraw it
using GdipDrawImageRectRectI (which I use to draw items on my planning and
work very well) instead of redrawing completly the background using
rectangle, line, ... functions.

I tried a lot of thing to save a copy of my background before drawing the
items (GdipCreateBitmapFromGraphics, GdipSaveImageToFile, ...) but I'am not
able to get this background saved. For example, the function
GdipCreateBitmapFromGraphics send back 0 (everything ok) but when I try to
draw the resulting image, nothing. (actually, I save the picture box on the
disk using dev tools native function and redraw the background using
GdipLoaImageFromFile/GdipDrawImageRectRectI combo wich is quite slow)

Do you have any idea of what I am doing wrong ?

My second problem is to refresh the screen after drawing. I tried API like
InvalidateRect, InvalidateRgn, ... to no avail, if I move another windows on
top of my program and then remove it ... the screen refresh correctly (my
software development tools don't have redraw property, I must use an API)

Any help will be much apreciated.

As English is not my native language, if you need me too explain better,
please ask.

Many thanks,

Albert P.


Thorsten Albers

unread,
Oct 6, 2009, 7:42:00 AM10/6/09
to
Albert P. <In...@gnito.com> schrieb im Beitrag
<4aca1a3e$0$932$ba4a...@news.orange.fr>...

> I would like to make a copy of this background and when I need it redraw
it
> using GdipDrawImageRectRectI (which I use to draw items on my planning
and
> work very well) instead of redrawing completly the background using
> rectangle, line, ... functions.
>
> I tried a lot of thing to save a copy of my background before drawing the

> items (GdipCreateBitmapFromGraphics, GdipSaveImageToFile, ...) but I'am
not
> able to get this background saved. For example, the function
> GdipCreateBitmapFromGraphics send back 0 (everything ok) but when I try
to
> draw the resulting image, nothing. (actually, I save the picture box on
the
> disk using dev tools native function and redraw the background using
> GdipLoaImageFromFile/GdipDrawImageRectRectI combo wich is quite slow)
>
> Do you have any idea of what I am doing wrong ?

> My second problem is to refresh the screen after drawing. I tried API
like
> InvalidateRect, InvalidateRgn, ... to no avail, if I move another windows
on
> top of my program and then remove it ... the screen refresh correctly (my

> software development tools don't have redraw property, I must use an API)

Without knowing your "software development tools" and without having seen
any code of yours it will be very, very difficult to tell what is going
wrong...

A general plot:

- Hold a graphics object in memory
- Draw the contents of graphics object to the drawing surface (e.g. VB
picture box control) of you application

a) if the contents of the graphics object has changed

In this case you only have to (re)draw the changed section(s)

b) if the drawing surface of you application has been (partly) erased etc.

In VB you have to redraw the whole drawing surface since the Paint event
doesn't provide any information on which part of the surface has been
erased etc.

--
Thorsten Albers

albers (a) uni-freiburg.de

Albert P.

unread,
Oct 6, 2009, 7:59:46 AM10/6/09
to

"Thorsten Albers" <alber...@THISuni-freiburg.de> a �crit dans le message
de news: 01ca466a$b13eefd0$ab01a8c0@thalk8s8x...

Thanks for your time,

Dev tools is Windev .. a french dev tools software which work in most of the
way like VB (usually I test api in VB6 and then adapt the code to windev)

My main problem is not about the code but more about which function to use.

If you have any idea or a link to some vb example ... msdn documentation
about GDI+ is quite confusing for me.

Albert P.


Thorsten Albers

unread,
Oct 6, 2009, 11:34:29 AM10/6/09
to

Albert P. <In...@gnito.com> schrieb im Beitrag
<4acb3151$0$1000$ba4a...@news.orange.fr>...

> Dev tools is Windev .. a french dev tools software which work in most of
the
> way like VB (usually I test api in VB6 and then adapt the code to windev)
>
> My main problem is not about the code but more about which function to
use.
>
> If you have any idea or a link to some vb example ... msdn documentation
> about GDI+ is quite confusing for me.

Presumably nobody here in this group wants to spend his time to give you a
complete new code solution. Instead (the relevant parts of) your existing
code should be posted in order that we can see where you should modify
and/or extend your code.

Albert P.

unread,
Oct 8, 2009, 4:22:09 AM10/8/09
to

"Thorsten Albers" <alber...@THISuni-freiburg.de> a �crit dans le message
de news: 01ca469a$7e655b00$ab01a8c0@thalk8s8x...

Hello,

It's always difficults when peoples try to communicate ... even more because
I am not a very good english writer.

I am not looking for a complete solution. I am just looking for a track to
follow to solve my problems : 1) copy my graphics object into a image object
so I can redraw it ... and 2) force windows to redraw my windows

For the 1rst problem here are the suggestion made on another forum : Create
a graphic objet based on an Image object, draw the fixed backgroup on this
one. Draw this image into the "picture" graphic objet and then draw the
items. When I need to redraw my picture, I just have to redraw the
background image and refresh the items, will try this solution today.

For the 2nd problems tried a lot of things (invalidateRect, invalidateRgn,
...) but with no success, I will try for the redrawing of all the windows
like you suggested for vb.

Albert P.


Nobody

unread,
Oct 8, 2009, 1:39:43 PM10/8/09
to
You will need this type library to use GDI+ easily in VB5/6. You don't need
to install this type library file on the end user's computer, you only need
it on the development machine. The end user needs to have XP or after, or
install the redistributable on Windows 98+ before running your program.

http://vbaccelerator.com/home/VB/Type_Libraries/GDIPlus_Type_Library/article.asp

The page above has a link to a sample, and there are more samples here:

http://vbaccelerator.com/home/VB/Code/vbMedia/Using_GDI_Plus/index.asp


Albert P.

unread,
Oct 9, 2009, 2:48:32 AM10/9/09
to

"Nobody" <nob...@nobody.com> a �crit dans le message de news:
OKGBi5DS...@TK2MSFTNGP02.phx.gbl...

Many thanks,

I will take a look at those links.

Regards,

Albert P.


0 new messages