Draw an Image on my Form | | |
Hi,
I have an inherited DataGrid, that does lots of extra stuff. For exemple
drawing a backgroundimage in every cell. The problem is that it's taking too
much time (using gdi+), so I want to do it using DirectX. I downloaded
already the DSK etc, but I can't find how I need to draw an image on a given
position. I don't need stuff to write advanced 3D-games, just painting that
image. Can anybody help me with this? I'm already looking for this the whole
afternoon :-/
I learned already that I shouldn't use DirectDraw (not supported anymore)
but Direct3D? But that's really all I know yet.
Basicly I jsut need to be able to draw an imahe (jpg, bitmap) on a Form in
VB.NET: as simple and as fast as possible.. :-)
Thanks a lot in advance,
Pieter | | | | re: Draw an Image on my Form
Have you timed to find out what the problem is ? DirectX would more likely
help if you repeateadly draw the whole (updated) thing. Here you just have
to draw this one time before there is some other kind of interaction.
Before switching to a whole new method I would investigate (in particular I
would time) the current code to find out where is spent the time budget...
(and next time thanks for trying to narrow down the groups to which you
posts).
--
Patrice
"DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
news:ekI$dC4kFHA.1412@TK2MSFTNGP09.phx.gbl...[color=blue]
> Hi,
>
> I have an inherited DataGrid, that does lots of extra stuff. For exemple
> drawing a backgroundimage in every cell. The problem is that it's taking[/color]
too[color=blue]
> much time (using gdi+), so I want to do it using DirectX. I downloaded
> already the DSK etc, but I can't find how I need to draw an image on a[/color]
given[color=blue]
> position. I don't need stuff to write advanced 3D-games, just painting[/color]
that[color=blue]
> image. Can anybody help me with this? I'm already looking for this the[/color]
whole[color=blue]
> afternoon :-/
>
> I learned already that I shouldn't use DirectDraw (not supported anymore)
> but Direct3D? But that's really all I know yet.
>
> Basicly I jsut need to be able to draw an imahe (jpg, bitmap) on a Form in
> VB.NET: as simple and as fast as possible.. :-)
>
> Thanks a lot in advance,
>
> Pieter
>
>[/color] | | | | re: Draw an Image on my Form
Well that's exactly what made me decide which to use DirectX: for every cell
it has to paint an image, and this has to happen on every paint of my
datagrid. So everytilme somebody scrolls, clicks in it, etc. I timed it, and
it takes the most time of my whole application (after using my application
for some seconds it has painted the same hing already more tahn 4000
times...) ! I'm trying to make it faster tha past days, and imrpoved it
already a lot, but I saw the only improvement i can make now is using
DirectX...
"Patrice" <nobody@nowhere.com> wrote in message
news:eRIXDK4kFHA.3568@tk2msftngp13.phx.gbl...[color=blue]
> Have you timed to find out what the problem is ? DirectX would more likely
> help if you repeateadly draw the whole (updated) thing. Here you just[/color]
have[color=blue]
> to draw this one time before there is some other kind of interaction.
>
> Before switching to a whole new method I would investigate (in particular[/color]
I[color=blue]
> would time) the current code to find out where is spent the time budget...
>
> (and next time thanks for trying to narrow down the groups to which you
> posts).
> --
> Patrice
>
> "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> news:ekI$dC4kFHA.1412@TK2MSFTNGP09.phx.gbl...[color=green]
> > Hi,
> >
> > I have an inherited DataGrid, that does lots of extra stuff. For exemple
> > drawing a backgroundimage in every cell. The problem is that it's taking[/color]
> too[color=green]
> > much time (using gdi+), so I want to do it using DirectX. I downloaded
> > already the DSK etc, but I can't find how I need to draw an image on a[/color]
> given[color=green]
> > position. I don't need stuff to write advanced 3D-games, just painting[/color]
> that[color=green]
> > image. Can anybody help me with this? I'm already looking for this the[/color]
> whole[color=green]
> > afternoon :-/
> >
> > I learned already that I shouldn't use DirectDraw (not supported[/color][/color]
anymore)[color=blue][color=green]
> > but Direct3D? But that's really all I know yet.
> >
> > Basicly I jsut need to be able to draw an imahe (jpg, bitmap) on a Form[/color][/color]
in[color=blue][color=green]
> > VB.NET: as simple and as fast as possible.. :-)
> >
> > Thanks a lot in advance,
> >
> > Pieter
> >
> >[/color]
>
>[/color] | | | | re: Draw an Image on my Form
If you switch to DX, you will need to re-implement your datagrid in DX and
paint all the data, etc. DX and GDI are very, very different.
"DraguVaso" <pietercoucke@hotmail.com> wrote in message
news:eyyxiT4kFHA.3936@TK2MSFTNGP10.phx.gbl...[color=blue]
> Well that's exactly what made me decide which to use DirectX: for every
> cell
> it has to paint an image, and this has to happen on every paint of my
> datagrid. So everytilme somebody scrolls, clicks in it, etc. I timed it,
> and
> it takes the most time of my whole application (after using my application
> for some seconds it has painted the same hing already more tahn 4000
> times...) ! I'm trying to make it faster tha past days, and imrpoved it
> already a lot, but I saw the only improvement i can make now is using
> DirectX...
>
>
> "Patrice" <nobody@nowhere.com> wrote in message
> news:eRIXDK4kFHA.3568@tk2msftngp13.phx.gbl...[color=green]
>> Have you timed to find out what the problem is ? DirectX would more
>> likely
>> help if you repeateadly draw the whole (updated) thing. Here you just[/color]
> have[color=green]
>> to draw this one time before there is some other kind of interaction.
>>
>> Before switching to a whole new method I would investigate (in particular[/color]
> I[color=green]
>> would time) the current code to find out where is spent the time
>> budget...
>>
>> (and next time thanks for trying to narrow down the groups to which you
>> posts).
>> --
>> Patrice
>>
>> "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
>> news:ekI$dC4kFHA.1412@TK2MSFTNGP09.phx.gbl...[color=darkred]
>> > Hi,
>> >
>> > I have an inherited DataGrid, that does lots of extra stuff. For
>> > exemple
>> > drawing a backgroundimage in every cell. The problem is that it's
>> > taking[/color]
>> too[color=darkred]
>> > much time (using gdi+), so I want to do it using DirectX. I downloaded
>> > already the DSK etc, but I can't find how I need to draw an image on a[/color]
>> given[color=darkred]
>> > position. I don't need stuff to write advanced 3D-games, just painting[/color]
>> that[color=darkred]
>> > image. Can anybody help me with this? I'm already looking for this the[/color]
>> whole[color=darkred]
>> > afternoon :-/
>> >
>> > I learned already that I shouldn't use DirectDraw (not supported[/color][/color]
> anymore)[color=green][color=darkred]
>> > but Direct3D? But that's really all I know yet.
>> >
>> > Basicly I jsut need to be able to draw an imahe (jpg, bitmap) on a Form[/color][/color]
> in[color=green][color=darkred]
>> > VB.NET: as simple and as fast as possible.. :-)
>> >
>> > Thanks a lot in advance,
>> >
>> > Pieter
>> >
>> >[/color]
>>
>>[/color]
>
>[/color] | | | | re: Draw an Image on my Form
I meant not as a whole but broken into steps. How much time does it take to
render how many cells ? What if you try to render a bitmap the same number
of times ? Especially keep ind mind that there are some subtles things that
could slow down the process such as stretching or doing some operations each
time you draw a cell rather than once etc...
You could also see if alternate approaches may help such as drawing the
datagrid as a bitmap with a transparent color on a backgrround bitmap.
DirectX is a low level API to discuss with graphics hardware and doesn't
provide any GDI integration. IMO would be much more complex and I still
suspect you have room left for improvments...
--
Patrice
"DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
news:eyyxiT4kFHA.3936@TK2MSFTNGP10.phx.gbl...[color=blue]
> Well that's exactly what made me decide which to use DirectX: for every[/color]
cell[color=blue]
> it has to paint an image, and this has to happen on every paint of my
> datagrid. So everytilme somebody scrolls, clicks in it, etc. I timed it,[/color]
and[color=blue]
> it takes the most time of my whole application (after using my application
> for some seconds it has painted the same hing already more tahn 4000
> times...) ! I'm trying to make it faster tha past days, and imrpoved it
> already a lot, but I saw the only improvement i can make now is using
> DirectX...
>
>
> "Patrice" <nobody@nowhere.com> wrote in message
> news:eRIXDK4kFHA.3568@tk2msftngp13.phx.gbl...[color=green]
> > Have you timed to find out what the problem is ? DirectX would more[/color][/color]
likely[color=blue][color=green]
> > help if you repeateadly draw the whole (updated) thing. Here you just[/color]
> have[color=green]
> > to draw this one time before there is some other kind of interaction.
> >
> > Before switching to a whole new method I would investigate (in[/color][/color]
particular[color=blue]
> I[color=green]
> > would time) the current code to find out where is spent the time[/color][/color]
budget...[color=blue][color=green]
> >
> > (and next time thanks for trying to narrow down the groups to which you
> > posts).
> > --
> > Patrice
> >
> > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> > news:ekI$dC4kFHA.1412@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > > Hi,
> > >
> > > I have an inherited DataGrid, that does lots of extra stuff. For[/color][/color][/color]
exemple[color=blue][color=green][color=darkred]
> > > drawing a backgroundimage in every cell. The problem is that it's[/color][/color][/color]
taking[color=blue][color=green]
> > too[color=darkred]
> > > much time (using gdi+), so I want to do it using DirectX. I downloaded
> > > already the DSK etc, but I can't find how I need to draw an image on a[/color]
> > given[color=darkred]
> > > position. I don't need stuff to write advanced 3D-games, just painting[/color]
> > that[color=darkred]
> > > image. Can anybody help me with this? I'm already looking for this the[/color]
> > whole[color=darkred]
> > > afternoon :-/
> > >
> > > I learned already that I shouldn't use DirectDraw (not supported[/color][/color]
> anymore)[color=green][color=darkred]
> > > but Direct3D? But that's really all I know yet.
> > >
> > > Basicly I jsut need to be able to draw an imahe (jpg, bitmap) on a[/color][/color][/color]
Form[color=blue]
> in[color=green][color=darkred]
> > > VB.NET: as simple and as fast as possible.. :-)
> > >
> > > Thanks a lot in advance,
> > >
> > > Pieter
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: Draw an Image on my Form
You wont be able to do this with the standard datagrid, I think you will
need to find a third party grid that supports drawing an image in each cell
and then keeps that on its backbuffer and doesnt render the image with each
paint, or find an open source grid and modify for you needs.
James
--
Create interactive diagrams and flowcharts with ERM Diagram at http://www.crainiate.net
Take the ERM Tour at http://www.flowchartcontrol.com
"DraguVaso" <pietercoucke@hotmail.com> wrote in message
news:ekI$dC4kFHA.1412@TK2MSFTNGP09.phx.gbl...[color=blue]
> Hi,
>
> I have an inherited DataGrid, that does lots of extra stuff. For exemple
> drawing a backgroundimage in every cell. The problem is that it's taking
> too
> much time (using gdi+), so I want to do it using DirectX. I downloaded
> already the DSK etc, but I can't find how I need to draw an image on a
> given
> position. I don't need stuff to write advanced 3D-games, just painting
> that
> image. Can anybody help me with this? I'm already looking for this the
> whole
> afternoon :-/
>
> I learned already that I shouldn't use DirectDraw (not supported anymore)
> but Direct3D? But that's really all I know yet.
>
> Basicly I jsut need to be able to draw an imahe (jpg, bitmap) on a Form in
> VB.NET: as simple and as fast as possible.. :-)
>
> Thanks a lot in advance,
>
> Pieter
>
>[/color] | | | | re: Draw an Image on my Form
What method are you using ? Using a brush seems quite quick...
(narrowed down to
microsoft.public.dotnet.framework,microsoft.public .dotnet.framework.drawing,
microsoft.public.dotnet.general)
--
Patrice
"Patrice" <nobody@nowhere.com> a écrit dans le message de
news:O80zN%234kFHA.576@tk2msftngp13.phx.gbl...[color=blue]
> I meant not as a whole but broken into steps. How much time does it take[/color]
to[color=blue]
> render how many cells ? What if you try to render a bitmap the same number
> of times ? Especially keep ind mind that there are some subtles things[/color]
that[color=blue]
> could slow down the process such as stretching or doing some operations[/color]
each[color=blue]
> time you draw a cell rather than once etc...
>
> You could also see if alternate approaches may help such as drawing the
> datagrid as a bitmap with a transparent color on a backgrround bitmap.
>
> DirectX is a low level API to discuss with graphics hardware and doesn't
> provide any GDI integration. IMO would be much more complex and I still
> suspect you have room left for improvments...
>
> --
>
> Patrice
>
> "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> news:eyyxiT4kFHA.3936@TK2MSFTNGP10.phx.gbl...[color=green]
> > Well that's exactly what made me decide which to use DirectX: for every[/color]
> cell[color=green]
> > it has to paint an image, and this has to happen on every paint of my
> > datagrid. So everytilme somebody scrolls, clicks in it, etc. I timed it,[/color]
> and[color=green]
> > it takes the most time of my whole application (after using my[/color][/color]
application[color=blue][color=green]
> > for some seconds it has painted the same hing already more tahn 4000
> > times...) ! I'm trying to make it faster tha past days, and imrpoved it
> > already a lot, but I saw the only improvement i can make now is using
> > DirectX...
> >
> >
> > "Patrice" <nobody@nowhere.com> wrote in message
> > news:eRIXDK4kFHA.3568@tk2msftngp13.phx.gbl...[color=darkred]
> > > Have you timed to find out what the problem is ? DirectX would more[/color][/color]
> likely[color=green][color=darkred]
> > > help if you repeateadly draw the whole (updated) thing. Here you just[/color]
> > have[color=darkred]
> > > to draw this one time before there is some other kind of interaction.
> > >
> > > Before switching to a whole new method I would investigate (in[/color][/color]
> particular[color=green]
> > I[color=darkred]
> > > would time) the current code to find out where is spent the time[/color][/color]
> budget...[color=green][color=darkred]
> > >
> > > (and next time thanks for trying to narrow down the groups to which[/color][/color][/color]
you[color=blue][color=green][color=darkred]
> > > posts).
> > > --
> > > Patrice
> > >
> > > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> > > news:ekI$dC4kFHA.1412@TK2MSFTNGP09.phx.gbl...
> > > > Hi,
> > > >
> > > > I have an inherited DataGrid, that does lots of extra stuff. For[/color][/color]
> exemple[color=green][color=darkred]
> > > > drawing a backgroundimage in every cell. The problem is that it's[/color][/color]
> taking[color=green][color=darkred]
> > > too
> > > > much time (using gdi+), so I want to do it using DirectX. I[/color][/color][/color]
downloaded[color=blue][color=green][color=darkred]
> > > > already the DSK etc, but I can't find how I need to draw an image on[/color][/color][/color]
a[color=blue][color=green][color=darkred]
> > > given
> > > > position. I don't need stuff to write advanced 3D-games, just[/color][/color][/color]
painting[color=blue][color=green][color=darkred]
> > > that
> > > > image. Can anybody help me with this? I'm already looking for this[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > whole
> > > > afternoon :-/
> > > >
> > > > I learned already that I shouldn't use DirectDraw (not supported[/color]
> > anymore)[color=darkred]
> > > > but Direct3D? But that's really all I know yet.
> > > >
> > > > Basicly I jsut need to be able to draw an imahe (jpg, bitmap) on a[/color][/color]
> Form[color=green]
> > in[color=darkred]
> > > > VB.NET: as simple and as fast as possible.. :-)
> > > >
> > > > Thanks a lot in advance,
> > > >
> > > > Pieter
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: Draw an Image on my Form
Yes I am able to do it with the standard grid: I'm actually doing it
already. But I just want to be able to do it with DirectX....
So my question is still: how do I paint an image using directX? does nobody
knows this? :-S
"James Westgate" <jameswestgate@nospam.nospam> wrote in message
news:%236FWZ94kFHA.572@TK2MSFTNGP15.phx.gbl...[color=blue]
> You wont be able to do this with the standard datagrid, I think you will
> need to find a third party grid that supports drawing an image in each[/color]
cell[color=blue]
> and then keeps that on its backbuffer and doesnt render the image with[/color]
each[color=blue]
> paint, or find an open source grid and modify for you needs.
>
> James
>
> --
> Create interactive diagrams and flowcharts with ERM Diagram at
> http://www.crainiate.net
>
> Take the ERM Tour at http://www.flowchartcontrol.com
>
> "DraguVaso" <pietercoucke@hotmail.com> wrote in message
> news:ekI$dC4kFHA.1412@TK2MSFTNGP09.phx.gbl...[color=green]
> > Hi,
> >
> > I have an inherited DataGrid, that does lots of extra stuff. For exemple
> > drawing a backgroundimage in every cell. The problem is that it's taking
> > too
> > much time (using gdi+), so I want to do it using DirectX. I downloaded
> > already the DSK etc, but I can't find how I need to draw an image on a
> > given
> > position. I don't need stuff to write advanced 3D-games, just painting
> > that
> > image. Can anybody help me with this? I'm already looking for this the
> > whole
> > afternoon :-/
> >
> > I learned already that I shouldn't use DirectDraw (not supported[/color][/color]
anymore)[color=blue][color=green]
> > but Direct3D? But that's really all I know yet.
> >
> > Basicly I jsut need to be able to draw an imahe (jpg, bitmap) on a Form[/color][/color]
in[color=blue][color=green]
> > VB.NET: as simple and as fast as possible.. :-)
> >
> > Thanks a lot in advance,
> >
> > Pieter
> >
> >[/color]
>
>[/color] | | | | re: Draw an Image on my Form
I prerender my images: that speeded up things a lot.
I put al my images into the Format32bppPArgb-Pixelformat
I use double buffering
I also use
g.InterpolationMode = Drawing2D.InterpolationMode.NearestNeighbor
g.CompositingQuality = Drawing2D.CompositingQuality.HighSpeed
g.SmoothingMode = Drawing2D.SmoothingMode.HighSpeed
I don't paint a BackGround to gain time.
I used a code profiler to determine the bottlenecks and speed up several
things. the only thing that still takes much time is the method which is
actually paintng every time the image: "g.DrawImage(fe.BackgroundImage,
rectB)". I know i could get faster using DrawimageUnscaled, but because ot
he cell's width etc changes I can't use it here.
So I really think there isn't any more room left to make other improvements.
So that's why i really would like to know how I have to paint an image with
DirectX. Is this really such a hard question? Just painting an image with
DirectX?
"Patrice" <nobody@nowhere.com> wrote in message
news:emegHM5kFHA.2920@TK2MSFTNGP14.phx.gbl...[color=blue]
> What method are you using ? Using a brush seems quite quick...
> (narrowed down to
>[/color]
microsoft.public.dotnet.framework,microsoft.public .dotnet.framework.drawing,[color=blue]
> microsoft.public.dotnet.general)
>
>
> --
> Patrice
>
> "Patrice" <nobody@nowhere.com> a écrit dans le message de
> news:O80zN%234kFHA.576@tk2msftngp13.phx.gbl...[color=green]
> > I meant not as a whole but broken into steps. How much time does it take[/color]
> to[color=green]
> > render how many cells ? What if you try to render a bitmap the same[/color][/color]
number[color=blue][color=green]
> > of times ? Especially keep ind mind that there are some subtles things[/color]
> that[color=green]
> > could slow down the process such as stretching or doing some operations[/color]
> each[color=green]
> > time you draw a cell rather than once etc...
> >
> > You could also see if alternate approaches may help such as drawing the
> > datagrid as a bitmap with a transparent color on a backgrround bitmap.
> >
> > DirectX is a low level API to discuss with graphics hardware and doesn't
> > provide any GDI integration. IMO would be much more complex and I still
> > suspect you have room left for improvments...
> >
> > --
> >
> > Patrice
> >
> > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> > news:eyyxiT4kFHA.3936@TK2MSFTNGP10.phx.gbl...[color=darkred]
> > > Well that's exactly what made me decide which to use DirectX: for[/color][/color][/color]
every[color=blue][color=green]
> > cell[color=darkred]
> > > it has to paint an image, and this has to happen on every paint of my
> > > datagrid. So everytilme somebody scrolls, clicks in it, etc. I timed[/color][/color][/color]
it,[color=blue][color=green]
> > and[color=darkred]
> > > it takes the most time of my whole application (after using my[/color][/color]
> application[color=green][color=darkred]
> > > for some seconds it has painted the same hing already more tahn 4000
> > > times...) ! I'm trying to make it faster tha past days, and imrpoved[/color][/color][/color]
it[color=blue][color=green][color=darkred]
> > > already a lot, but I saw the only improvement i can make now is using
> > > DirectX...
> > >
> > >
> > > "Patrice" <nobody@nowhere.com> wrote in message
> > > news:eRIXDK4kFHA.3568@tk2msftngp13.phx.gbl...
> > > > Have you timed to find out what the problem is ? DirectX would more[/color]
> > likely[color=darkred]
> > > > help if you repeateadly draw the whole (updated) thing. Here you[/color][/color][/color]
just[color=blue][color=green][color=darkred]
> > > have
> > > > to draw this one time before there is some other kind of[/color][/color][/color]
interaction.[color=blue][color=green][color=darkred]
> > > >
> > > > Before switching to a whole new method I would investigate (in[/color]
> > particular[color=darkred]
> > > I
> > > > would time) the current code to find out where is spent the time[/color]
> > budget...[color=darkred]
> > > >
> > > > (and next time thanks for trying to narrow down the groups to which[/color][/color]
> you[color=green][color=darkred]
> > > > posts).
> > > > --
> > > > Patrice
> > > >
> > > > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> > > > news:ekI$dC4kFHA.1412@TK2MSFTNGP09.phx.gbl...
> > > > > Hi,
> > > > >
> > > > > I have an inherited DataGrid, that does lots of extra stuff. For[/color]
> > exemple[color=darkred]
> > > > > drawing a backgroundimage in every cell. The problem is that it's[/color]
> > taking[color=darkred]
> > > > too
> > > > > much time (using gdi+), so I want to do it using DirectX. I[/color][/color]
> downloaded[color=green][color=darkred]
> > > > > already the DSK etc, but I can't find how I need to draw an image[/color][/color][/color]
on[color=blue]
> a[color=green][color=darkred]
> > > > given
> > > > > position. I don't need stuff to write advanced 3D-games, just[/color][/color]
> painting[color=green][color=darkred]
> > > > that
> > > > > image. Can anybody help me with this? I'm already looking for this[/color][/color]
> the[color=green][color=darkred]
> > > > whole
> > > > > afternoon :-/
> > > > >
> > > > > I learned already that I shouldn't use DirectDraw (not supported
> > > anymore)
> > > > > but Direct3D? But that's really all I know yet.
> > > > >
> > > > > Basicly I jsut need to be able to draw an imahe (jpg, bitmap) on a[/color]
> > Form[color=darkred]
> > > in
> > > > > VB.NET: as simple and as fast as possible.. :-)
> > > > >
> > > > > Thanks a lot in advance,
> > > > >
> > > > > Pieter
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: Draw an Image on my Form
I don't get it really: How can I use a Brush it I want to paint an image? I
thought a Brush is jsut one color, not an image? Or am I wrong?
"Patrice" <nobody@nowhere.com> wrote in message
news:emegHM5kFHA.2920@TK2MSFTNGP14.phx.gbl...[color=blue]
> What method are you using ? Using a brush seems quite quick...
> (narrowed down to
>[/color]
microsoft.public.dotnet.framework,microsoft.public .dotnet.framework.drawing,[color=blue]
> microsoft.public.dotnet.general)
>
>
> --
> Patrice
>
> "Patrice" <nobody@nowhere.com> a écrit dans le message de
> news:O80zN%234kFHA.576@tk2msftngp13.phx.gbl...[color=green]
> > I meant not as a whole but broken into steps. How much time does it take[/color]
> to[color=green]
> > render how many cells ? What if you try to render a bitmap the same[/color][/color]
number[color=blue][color=green]
> > of times ? Especially keep ind mind that there are some subtles things[/color]
> that[color=green]
> > could slow down the process such as stretching or doing some operations[/color]
> each[color=green]
> > time you draw a cell rather than once etc...
> >
> > You could also see if alternate approaches may help such as drawing the
> > datagrid as a bitmap with a transparent color on a backgrround bitmap.
> >
> > DirectX is a low level API to discuss with graphics hardware and doesn't
> > provide any GDI integration. IMO would be much more complex and I still
> > suspect you have room left for improvments...
> >
> > --
> >
> > Patrice
> >
> > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> > news:eyyxiT4kFHA.3936@TK2MSFTNGP10.phx.gbl...[color=darkred]
> > > Well that's exactly what made me decide which to use DirectX: for[/color][/color][/color]
every[color=blue][color=green]
> > cell[color=darkred]
> > > it has to paint an image, and this has to happen on every paint of my
> > > datagrid. So everytilme somebody scrolls, clicks in it, etc. I timed[/color][/color][/color]
it,[color=blue][color=green]
> > and[color=darkred]
> > > it takes the most time of my whole application (after using my[/color][/color]
> application[color=green][color=darkred]
> > > for some seconds it has painted the same hing already more tahn 4000
> > > times...) ! I'm trying to make it faster tha past days, and imrpoved[/color][/color][/color]
it[color=blue][color=green][color=darkred]
> > > already a lot, but I saw the only improvement i can make now is using
> > > DirectX...
> > >
> > >
> > > "Patrice" <nobody@nowhere.com> wrote in message
> > > news:eRIXDK4kFHA.3568@tk2msftngp13.phx.gbl...
> > > > Have you timed to find out what the problem is ? DirectX would more[/color]
> > likely[color=darkred]
> > > > help if you repeateadly draw the whole (updated) thing. Here you[/color][/color][/color]
just[color=blue][color=green][color=darkred]
> > > have
> > > > to draw this one time before there is some other kind of[/color][/color][/color]
interaction.[color=blue][color=green][color=darkred]
> > > >
> > > > Before switching to a whole new method I would investigate (in[/color]
> > particular[color=darkred]
> > > I
> > > > would time) the current code to find out where is spent the time[/color]
> > budget...[color=darkred]
> > > >
> > > > (and next time thanks for trying to narrow down the groups to which[/color][/color]
> you[color=green][color=darkred]
> > > > posts).
> > > > --
> > > > Patrice
> > > >
> > > > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> > > > news:ekI$dC4kFHA.1412@TK2MSFTNGP09.phx.gbl...
> > > > > Hi,
> > > > >
> > > > > I have an inherited DataGrid, that does lots of extra stuff. For[/color]
> > exemple[color=darkred]
> > > > > drawing a backgroundimage in every cell. The problem is that it's[/color]
> > taking[color=darkred]
> > > > too
> > > > > much time (using gdi+), so I want to do it using DirectX. I[/color][/color]
> downloaded[color=green][color=darkred]
> > > > > already the DSK etc, but I can't find how I need to draw an image[/color][/color][/color]
on[color=blue]
> a[color=green][color=darkred]
> > > > given
> > > > > position. I don't need stuff to write advanced 3D-games, just[/color][/color]
> painting[color=green][color=darkred]
> > > > that
> > > > > image. Can anybody help me with this? I'm already looking for this[/color][/color]
> the[color=green][color=darkred]
> > > > whole
> > > > > afternoon :-/
> > > > >
> > > > > I learned already that I shouldn't use DirectDraw (not supported
> > > anymore)
> > > > > but Direct3D? But that's really all I know yet.
> > > > >
> > > > > Basicly I jsut need to be able to draw an imahe (jpg, bitmap) on a[/color]
> > Form[color=darkred]
> > > in
> > > > > VB.NET: as simple and as fast as possible.. :-)
> > > > >
> > > > > Thanks a lot in advance,
> > > > >
> > > > > Pieter
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: Draw an Image on my Form
What I meant is that you can use directx onto a standard control and that
you need to fundamentally change the way you are doing things.
Good luck though!
J
#
"DraguVaso" <pietercoucke@hotmail.com> wrote in message
news:OMOCnMClFHA.3580@TK2MSFTNGP09.phx.gbl...[color=blue]
> Yes I am able to do it with the standard grid: I'm actually doing it
> already. But I just want to be able to do it with DirectX....
>
> So my question is still: how do I paint an image using directX? does
> nobody
> knows this? :-S
>
> "James Westgate" <jameswestgate@nospam.nospam> wrote in message
> news:%236FWZ94kFHA.572@TK2MSFTNGP15.phx.gbl...[color=green]
>> You wont be able to do this with the standard datagrid, I think you will
>> need to find a third party grid that supports drawing an image in each[/color]
> cell[color=green]
>> and then keeps that on its backbuffer and doesnt render the image with[/color]
> each[color=green]
>> paint, or find an open source grid and modify for you needs.
>>
>> James
>>
>> --
>> Create interactive diagrams and flowcharts with ERM Diagram at
>> http://www.crainiate.net
>>
>> Take the ERM Tour at http://www.flowchartcontrol.com
>>
>> "DraguVaso" <pietercoucke@hotmail.com> wrote in message
>> news:ekI$dC4kFHA.1412@TK2MSFTNGP09.phx.gbl...[color=darkred]
>> > Hi,
>> >
>> > I have an inherited DataGrid, that does lots of extra stuff. For
>> > exemple
>> > drawing a backgroundimage in every cell. The problem is that it's
>> > taking
>> > too
>> > much time (using gdi+), so I want to do it using DirectX. I downloaded
>> > already the DSK etc, but I can't find how I need to draw an image on a
>> > given
>> > position. I don't need stuff to write advanced 3D-games, just painting
>> > that
>> > image. Can anybody help me with this? I'm already looking for this the
>> > whole
>> > afternoon :-/
>> >
>> > I learned already that I shouldn't use DirectDraw (not supported[/color][/color]
> anymore)[color=green][color=darkred]
>> > but Direct3D? But that's really all I know yet.
>> >
>> > Basicly I jsut need to be able to draw an imahe (jpg, bitmap) on a Form[/color][/color]
> in[color=green][color=darkred]
>> > VB.NET: as simple and as fast as possible.. :-)
>> >
>> > Thanks a lot in advance,
>> >
>> > Pieter
>> >
>> >[/color]
>>
>>[/color]
>
>[/color] | | | | re: Draw an Image on my Form
See the TexturedBrush class. A brush is used to "fill in" something. It can
be a "solid" color but also an image. See it as a kind of wallpaper (sorry
for my poor English).
So you want to render in each cell a different bitmap ? Each bitmap is
stretched to fit in the cell ?
I'm not sure what is the graphics aspect you want but you could also see if
a new strategy could help such as grabbing the datagrid as a bitmap and
combining it as a whole with perhaps a transparent color.
Using DirectX is IMO a bit risky for such an application as it will
introduce a new dependency (for example if the target platform doesn't have
DX9 installed it won't work) plus the result will depend on the hardware
support and finally you'll have likely some problems as you'll likely have
to combine GDI/DirectX.
As a whole it doesn't seem to me that such a requirement should trigger the
use of DirectX. If you really want to go this route, you could perhaps try
to render a stretched bitmap "cells" time at an arbitrary location. It
should already give you the maximum improvment you could get over using
GDI+.
Good luck.
--
Patrice
"DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
news:%23VEIkRClFHA.3656@TK2MSFTNGP09.phx.gbl...[color=blue]
> I don't get it really: How can I use a Brush it I want to paint an image?[/color]
I[color=blue]
> thought a Brush is jsut one color, not an image? Or am I wrong?
>
>
> "Patrice" <nobody@nowhere.com> wrote in message
> news:emegHM5kFHA.2920@TK2MSFTNGP14.phx.gbl...[color=green]
> > What method are you using ? Using a brush seems quite quick...
> > (narrowed down to
> >[/color]
>[/color]
microsoft.public.dotnet.framework,microsoft.public .dotnet.framework.drawing,[color=blue][color=green]
> > microsoft.public.dotnet.general)
> >
> >
> > --
> > Patrice
> >
> > "Patrice" <nobody@nowhere.com> a écrit dans le message de
> > news:O80zN%234kFHA.576@tk2msftngp13.phx.gbl...[color=darkred]
> > > I meant not as a whole but broken into steps. How much time does it[/color][/color][/color]
take[color=blue][color=green]
> > to[color=darkred]
> > > render how many cells ? What if you try to render a bitmap the same[/color][/color]
> number[color=green][color=darkred]
> > > of times ? Especially keep ind mind that there are some subtles things[/color]
> > that[color=darkred]
> > > could slow down the process such as stretching or doing some[/color][/color][/color]
operations[color=blue][color=green]
> > each[color=darkred]
> > > time you draw a cell rather than once etc...
> > >
> > > You could also see if alternate approaches may help such as drawing[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > datagrid as a bitmap with a transparent color on a backgrround bitmap.
> > >
> > > DirectX is a low level API to discuss with graphics hardware and[/color][/color][/color]
doesn't[color=blue][color=green][color=darkred]
> > > provide any GDI integration. IMO would be much more complex and I[/color][/color][/color]
still[color=blue][color=green][color=darkred]
> > > suspect you have room left for improvments...
> > >
> > > --
> > >
> > > Patrice
> > >
> > > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> > > news:eyyxiT4kFHA.3936@TK2MSFTNGP10.phx.gbl...
> > > > Well that's exactly what made me decide which to use DirectX: for[/color][/color]
> every[color=green][color=darkred]
> > > cell
> > > > it has to paint an image, and this has to happen on every paint of[/color][/color][/color]
my[color=blue][color=green][color=darkred]
> > > > datagrid. So everytilme somebody scrolls, clicks in it, etc. I timed[/color][/color]
> it,[color=green][color=darkred]
> > > and
> > > > it takes the most time of my whole application (after using my[/color]
> > application[color=darkred]
> > > > for some seconds it has painted the same hing already more tahn 4000
> > > > times...) ! I'm trying to make it faster tha past days, and imrpoved[/color][/color]
> it[color=green][color=darkred]
> > > > already a lot, but I saw the only improvement i can make now is[/color][/color][/color]
using[color=blue][color=green][color=darkred]
> > > > DirectX...
> > > >
> > > >
> > > > "Patrice" <nobody@nowhere.com> wrote in message
> > > > news:eRIXDK4kFHA.3568@tk2msftngp13.phx.gbl...
> > > > > Have you timed to find out what the problem is ? DirectX would[/color][/color][/color]
more[color=blue][color=green][color=darkred]
> > > likely
> > > > > help if you repeateadly draw the whole (updated) thing. Here you[/color][/color]
> just[color=green][color=darkred]
> > > > have
> > > > > to draw this one time before there is some other kind of[/color][/color]
> interaction.[color=green][color=darkred]
> > > > >
> > > > > Before switching to a whole new method I would investigate (in
> > > particular
> > > > I
> > > > > would time) the current code to find out where is spent the time
> > > budget...
> > > > >
> > > > > (and next time thanks for trying to narrow down the groups to[/color][/color][/color]
which[color=blue][color=green]
> > you[color=darkred]
> > > > > posts).
> > > > > --
> > > > > Patrice
> > > > >
> > > > > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> > > > > news:ekI$dC4kFHA.1412@TK2MSFTNGP09.phx.gbl...
> > > > > > Hi,
> > > > > >
> > > > > > I have an inherited DataGrid, that does lots of extra stuff. For
> > > exemple
> > > > > > drawing a backgroundimage in every cell. The problem is that[/color][/color][/color]
it's[color=blue][color=green][color=darkred]
> > > taking
> > > > > too
> > > > > > much time (using gdi+), so I want to do it using DirectX. I[/color]
> > downloaded[color=darkred]
> > > > > > already the DSK etc, but I can't find how I need to draw an[/color][/color][/color]
image[color=blue]
> on[color=green]
> > a[color=darkred]
> > > > > given
> > > > > > position. I don't need stuff to write advanced 3D-games, just[/color]
> > painting[color=darkred]
> > > > > that
> > > > > > image. Can anybody help me with this? I'm already looking for[/color][/color][/color]
this[color=blue][color=green]
> > the[color=darkred]
> > > > > whole
> > > > > > afternoon :-/
> > > > > >
> > > > > > I learned already that I shouldn't use DirectDraw (not supported
> > > > anymore)
> > > > > > but Direct3D? But that's really all I know yet.
> > > > > >
> > > > > > Basicly I jsut need to be able to draw an imahe (jpg, bitmap) on[/color][/color][/color]
a[color=blue][color=green][color=darkred]
> > > Form
> > > > in
> > > > > > VB.NET: as simple and as fast as possible.. :-)
> > > > > >
> > > > > > Thanks a lot in advance,
> > > > > >
> > > > > > Pieter
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: Draw an Image on my Form
As a side note if you have several cells with the same width/height you
could perhaps create a stretched version and use it to perform an
unstretched copy ?
--
"Patrice" <nobody@nowhere.com> a écrit dans le message de
news:%23L3JxLDlFHA.2472@TK2MSFTNGP15.phx.gbl...[color=blue]
> See the TexturedBrush class. A brush is used to "fill in" something. It[/color]
can[color=blue]
> be a "solid" color but also an image. See it as a kind of wallpaper (sorry
> for my poor English).
> So you want to render in each cell a different bitmap ? Each bitmap is
> stretched to fit in the cell ?
>
> I'm not sure what is the graphics aspect you want but you could also see[/color]
if[color=blue]
> a new strategy could help such as grabbing the datagrid as a bitmap and
> combining it as a whole with perhaps a transparent color.
>
> Using DirectX is IMO a bit risky for such an application as it will
> introduce a new dependency (for example if the target platform doesn't[/color]
have[color=blue]
> DX9 installed it won't work) plus the result will depend on the hardware
> support and finally you'll have likely some problems as you'll likely have
> to combine GDI/DirectX.
>
> As a whole it doesn't seem to me that such a requirement should trigger[/color]
the[color=blue]
> use of DirectX. If you really want to go this route, you could perhaps try
> to render a stretched bitmap "cells" time at an arbitrary location. It
> should already give you the maximum improvment you could get over using
> GDI+.
>
> Good luck.
> --
> Patrice
>
> "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> news:%23VEIkRClFHA.3656@TK2MSFTNGP09.phx.gbl...[color=green]
> > I don't get it really: How can I use a Brush it I want to paint an[/color][/color]
image?[color=blue]
> I[color=green]
> > thought a Brush is jsut one color, not an image? Or am I wrong?
> >
> >
> > "Patrice" <nobody@nowhere.com> wrote in message
> > news:emegHM5kFHA.2920@TK2MSFTNGP14.phx.gbl...[color=darkred]
> > > What method are you using ? Using a brush seems quite quick...
> > > (narrowed down to
> > >[/color]
> >[/color]
> microsoft.public.dotnet.framework,microsoft.public .dotnet.framework.drawin[/color]
g,[color=blue][color=green][color=darkred]
> > > microsoft.public.dotnet.general)
> > >
> > >
> > > --
> > > Patrice
> > >
> > > "Patrice" <nobody@nowhere.com> a écrit dans le message de
> > > news:O80zN%234kFHA.576@tk2msftngp13.phx.gbl...
> > > > I meant not as a whole but broken into steps. How much time does it[/color][/color]
> take[color=green][color=darkred]
> > > to
> > > > render how many cells ? What if you try to render a bitmap the same[/color]
> > number[color=darkred]
> > > > of times ? Especially keep ind mind that there are some subtles[/color][/color][/color]
things[color=blue][color=green][color=darkred]
> > > that
> > > > could slow down the process such as stretching or doing some[/color][/color]
> operations[color=green][color=darkred]
> > > each
> > > > time you draw a cell rather than once etc...
> > > >
> > > > You could also see if alternate approaches may help such as drawing[/color][/color]
> the[color=green][color=darkred]
> > > > datagrid as a bitmap with a transparent color on a backgrround[/color][/color][/color]
bitmap.[color=blue][color=green][color=darkred]
> > > >
> > > > DirectX is a low level API to discuss with graphics hardware and[/color][/color]
> doesn't[color=green][color=darkred]
> > > > provide any GDI integration. IMO would be much more complex and I[/color][/color]
> still[color=green][color=darkred]
> > > > suspect you have room left for improvments...
> > > >
> > > > --
> > > >
> > > > Patrice
> > > >
> > > > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> > > > news:eyyxiT4kFHA.3936@TK2MSFTNGP10.phx.gbl...
> > > > > Well that's exactly what made me decide which to use DirectX: for[/color]
> > every[color=darkred]
> > > > cell
> > > > > it has to paint an image, and this has to happen on every paint of[/color][/color]
> my[color=green][color=darkred]
> > > > > datagrid. So everytilme somebody scrolls, clicks in it, etc. I[/color][/color][/color]
timed[color=blue][color=green]
> > it,[color=darkred]
> > > > and
> > > > > it takes the most time of my whole application (after using my
> > > application
> > > > > for some seconds it has painted the same hing already more tahn[/color][/color][/color]
4000[color=blue][color=green][color=darkred]
> > > > > times...) ! I'm trying to make it faster tha past days, and[/color][/color][/color]
imrpoved[color=blue][color=green]
> > it[color=darkred]
> > > > > already a lot, but I saw the only improvement i can make now is[/color][/color]
> using[color=green][color=darkred]
> > > > > DirectX...
> > > > >
> > > > >
> > > > > "Patrice" <nobody@nowhere.com> wrote in message
> > > > > news:eRIXDK4kFHA.3568@tk2msftngp13.phx.gbl...
> > > > > > Have you timed to find out what the problem is ? DirectX would[/color][/color]
> more[color=green][color=darkred]
> > > > likely
> > > > > > help if you repeateadly draw the whole (updated) thing. Here[/color][/color][/color]
you[color=blue][color=green]
> > just[color=darkred]
> > > > > have
> > > > > > to draw this one time before there is some other kind of[/color]
> > interaction.[color=darkred]
> > > > > >
> > > > > > Before switching to a whole new method I would investigate (in
> > > > particular
> > > > > I
> > > > > > would time) the current code to find out where is spent the time
> > > > budget...
> > > > > >
> > > > > > (and next time thanks for trying to narrow down the groups to[/color][/color]
> which[color=green][color=darkred]
> > > you
> > > > > > posts).
> > > > > > --
> > > > > > Patrice
> > > > > >
> > > > > > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message[/color][/color][/color]
de[color=blue][color=green][color=darkred]
> > > > > > news:ekI$dC4kFHA.1412@TK2MSFTNGP09.phx.gbl...
> > > > > > > Hi,
> > > > > > >
> > > > > > > I have an inherited DataGrid, that does lots of extra stuff.[/color][/color][/color]
For[color=blue][color=green][color=darkred]
> > > > exemple
> > > > > > > drawing a backgroundimage in every cell. The problem is that[/color][/color]
> it's[color=green][color=darkred]
> > > > taking
> > > > > > too
> > > > > > > much time (using gdi+), so I want to do it using DirectX. I
> > > downloaded
> > > > > > > already the DSK etc, but I can't find how I need to draw an[/color][/color]
> image[color=green]
> > on[color=darkred]
> > > a
> > > > > > given
> > > > > > > position. I don't need stuff to write advanced 3D-games, just
> > > painting
> > > > > > that
> > > > > > > image. Can anybody help me with this? I'm already looking for[/color][/color]
> this[color=green][color=darkred]
> > > the
> > > > > > whole
> > > > > > > afternoon :-/
> > > > > > >
> > > > > > > I learned already that I shouldn't use DirectDraw (not[/color][/color][/color]
supported[color=blue][color=green][color=darkred]
> > > > > anymore)
> > > > > > > but Direct3D? But that's really all I know yet.
> > > > > > >
> > > > > > > Basicly I jsut need to be able to draw an imahe (jpg, bitmap)[/color][/color][/color]
on[color=blue]
> a[color=green][color=darkred]
> > > > Form
> > > > > in
> > > > > > > VB.NET: as simple and as fast as possible.. :-)
> > > > > > >
> > > > > > > Thanks a lot in advance,
> > > > > > >
> > > > > > > Pieter
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: Draw an Image on my Form
I'm pretty sure the answer is "you can't do it". GDI+ uses Graphics
objects, rectangles, polygons, lines, and Fill routines designed for 2D
drawing. DirectX uses Surface objects, vertexes, polygons (though not the
same as a GDI+ polygon), shaders, and renderers designed for 3D drawing.
GDI+ and DirectX are completely different models, built for completely
different tasks, and I don't believe there is any bridge mechanism between
them. Even if there were, it's likely all to be through Interop, which
could eat up all the speed gains you might get by drawing your image with
DirectX. Or, you'd have to do all the translation by hand in code -
essentially re-creating your DataGrid visual representation completely
within the DirectX environment. That's simply not practical.
This is what the folks have been trying to tell you with their posts: you
either need to go 100% DirectX (which means you're dropping the DataGrid
inheritance and writing your own completely from scratch), or 100% GDI+ -
you can't mix the two. Given that the DataGrid uses GDI+, the logical thing
to do is work to get acceptable performance from GDI+. Of course, you've
already said that you're not getting acceptable performance from GDI+, so
you're back to creating your own grid from scratch (using either drawing
library), purchasing one, or trying to get what you've got working.
If your problem is that your cells are not the same size as your background
image, and that they can be resized, you can approach it one of two ways:
allow your background image to be tiled (which can be done quite quickly
with a TextureBrush, and should perform well); or maintain a cache of all
distinct cell sizes, along with appropriately-sized background images, and
draw them into the cell (which may not help much, if the user does a lot of
resizing.) I am assuming that you're only drawing the background image on
visible DataGrid cells, but if not, that's another optimization that will
likely pay off quite well.
You could also consider going directly to the GDI BitBlt API call - I've
heard that the speed gains in doing that outweigh the cost of the Interop
call, but I haven't tested that.
- Scott
"DraguVaso" <pietercoucke@hotmail.com> wrote in message
news:OMOCnMClFHA.3580@TK2MSFTNGP09.phx.gbl...[color=blue]
> Yes I am able to do it with the standard grid: I'm actually doing it
> already. But I just want to be able to do it with DirectX....
>
> So my question is still: how do I paint an image using directX? does
> nobody
> knows this? :-S
>
> "James Westgate" <jameswestgate@nospam.nospam> wrote in message
> news:%236FWZ94kFHA.572@TK2MSFTNGP15.phx.gbl...[color=green]
>> You wont be able to do this with the standard datagrid, I think you will
>> need to find a third party grid that supports drawing an image in each[/color]
> cell[color=green]
>> and then keeps that on its backbuffer and doesnt render the image with[/color]
> each[color=green]
>> paint, or find an open source grid and modify for you needs.
>>
>> James
>>
>> --
>> Create interactive diagrams and flowcharts with ERM Diagram at
>> http://www.crainiate.net
>>
>> Take the ERM Tour at http://www.flowchartcontrol.com
>>
>> "DraguVaso" <pietercoucke@hotmail.com> wrote in message
>> news:ekI$dC4kFHA.1412@TK2MSFTNGP09.phx.gbl...[color=darkred]
>> > Hi,
>> >
>> > I have an inherited DataGrid, that does lots of extra stuff. For
>> > exemple
>> > drawing a backgroundimage in every cell. The problem is that it's
>> > taking
>> > too
>> > much time (using gdi+), so I want to do it using DirectX. I downloaded
>> > already the DSK etc, but I can't find how I need to draw an image on a
>> > given
>> > position. I don't need stuff to write advanced 3D-games, just painting
>> > that
>> > image. Can anybody help me with this? I'm already looking for this the
>> > whole
>> > afternoon :-/
>> >
>> > I learned already that I shouldn't use DirectDraw (not supported[/color][/color]
> anymore)[color=green][color=darkred]
>> > but Direct3D? But that's really all I know yet.
>> >
>> > Basicly I jsut need to be able to draw an imahe (jpg, bitmap) on a Form[/color][/color]
> in[color=green][color=darkred]
>> > VB.NET: as simple and as fast as possible.. :-)
>> >
>> > Thanks a lot in advance,
>> >
>> > Pieter
>> >
>> >[/color]
>>
>>[/color]
>
>[/color] | | | | re: Draw an Image on my Form
I'm trying to use the TextureBrush, but it doesn't give the effect Iwant it
to have: it doesn't put in every cell 1 image, but puts the image x times
next to each other, independent of the cell-sizes... What I need is: one
image for each cell, and the image should be adapted to the cell-size... I
tried with the Wrapmode.Clamp, but that just draws the image only one time:
in the left upper corner of my DataGrid... :-/
"Patrice" <nobody@nowhere.com> wrote in message
news:%23L3JxLDlFHA.2472@TK2MSFTNGP15.phx.gbl...[color=blue]
> See the TexturedBrush class. A brush is used to "fill in" something. It[/color]
can[color=blue]
> be a "solid" color but also an image. See it as a kind of wallpaper (sorry
> for my poor English).
> So you want to render in each cell a different bitmap ? Each bitmap is
> stretched to fit in the cell ?
>
> I'm not sure what is the graphics aspect you want but you could also see[/color]
if[color=blue]
> a new strategy could help such as grabbing the datagrid as a bitmap and
> combining it as a whole with perhaps a transparent color.
>
> Using DirectX is IMO a bit risky for such an application as it will
> introduce a new dependency (for example if the target platform doesn't[/color]
have[color=blue]
> DX9 installed it won't work) plus the result will depend on the hardware
> support and finally you'll have likely some problems as you'll likely have
> to combine GDI/DirectX.
>
> As a whole it doesn't seem to me that such a requirement should trigger[/color]
the[color=blue]
> use of DirectX. If you really want to go this route, you could perhaps try
> to render a stretched bitmap "cells" time at an arbitrary location. It
> should already give you the maximum improvment you could get over using
> GDI+.
>
> Good luck.
> --
> Patrice
>
> "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> news:%23VEIkRClFHA.3656@TK2MSFTNGP09.phx.gbl...[color=green]
> > I don't get it really: How can I use a Brush it I want to paint an[/color][/color]
image?[color=blue]
> I[color=green]
> > thought a Brush is jsut one color, not an image? Or am I wrong?
> >
> >
> > "Patrice" <nobody@nowhere.com> wrote in message
> > news:emegHM5kFHA.2920@TK2MSFTNGP14.phx.gbl...[color=darkred]
> > > What method are you using ? Using a brush seems quite quick...
> > > (narrowed down to
> > >[/color]
> >[/color]
>[/color]
microsoft.public.dotnet.framework,microsoft.public .dotnet.framework.drawing,[color=blue][color=green][color=darkred]
> > > microsoft.public.dotnet.general)
> > >
> > >
> > > --
> > > Patrice
> > >
> > > "Patrice" <nobody@nowhere.com> a écrit dans le message de
> > > news:O80zN%234kFHA.576@tk2msftngp13.phx.gbl...
> > > > I meant not as a whole but broken into steps. How much time does it[/color][/color]
> take[color=green][color=darkred]
> > > to
> > > > render how many cells ? What if you try to render a bitmap the same[/color]
> > number[color=darkred]
> > > > of times ? Especially keep ind mind that there are some subtles[/color][/color][/color]
things[color=blue][color=green][color=darkred]
> > > that
> > > > could slow down the process such as stretching or doing some[/color][/color]
> operations[color=green][color=darkred]
> > > each
> > > > time you draw a cell rather than once etc...
> > > >
> > > > You could also see if alternate approaches may help such as drawing[/color][/color]
> the[color=green][color=darkred]
> > > > datagrid as a bitmap with a transparent color on a backgrround[/color][/color][/color]
bitmap.[color=blue][color=green][color=darkred]
> > > >
> > > > DirectX is a low level API to discuss with graphics hardware and[/color][/color]
> doesn't[color=green][color=darkred]
> > > > provide any GDI integration. IMO would be much more complex and I[/color][/color]
> still[color=green][color=darkred]
> > > > suspect you have room left for improvments...
> > > >
> > > > --
> > > >
> > > > Patrice
> > > >
> > > > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> > > > news:eyyxiT4kFHA.3936@TK2MSFTNGP10.phx.gbl...
> > > > > Well that's exactly what made me decide which to use DirectX: for[/color]
> > every[color=darkred]
> > > > cell
> > > > > it has to paint an image, and this has to happen on every paint of[/color][/color]
> my[color=green][color=darkred]
> > > > > datagrid. So everytilme somebody scrolls, clicks in it, etc. I[/color][/color][/color]
timed[color=blue][color=green]
> > it,[color=darkred]
> > > > and
> > > > > it takes the most time of my whole application (after using my
> > > application
> > > > > for some seconds it has painted the same hing already more tahn[/color][/color][/color]
4000[color=blue][color=green][color=darkred]
> > > > > times...) ! I'm trying to make it faster tha past days, and[/color][/color][/color]
imrpoved[color=blue][color=green]
> > it[color=darkred]
> > > > > already a lot, but I saw the only improvement i can make now is[/color][/color]
> using[color=green][color=darkred]
> > > > > DirectX...
> > > > >
> > > > >
> > > > > "Patrice" <nobody@nowhere.com> wrote in message
> > > > > news:eRIXDK4kFHA.3568@tk2msftngp13.phx.gbl...
> > > > > > Have you timed to find out what the problem is ? DirectX would[/color][/color]
> more[color=green][color=darkred]
> > > > likely
> > > > > > help if you repeateadly draw the whole (updated) thing. Here[/color][/color][/color]
you[color=blue][color=green]
> > just[color=darkred]
> > > > > have
> > > > > > to draw this one time before there is some other kind of[/color]
> > interaction.[color=darkred]
> > > > > >
> > > > > > Before switching to a whole new method I would investigate (in
> > > > particular
> > > > > I
> > > > > > would time) the current code to find out where is spent the time
> > > > budget...
> > > > > >
> > > > > > (and next time thanks for trying to narrow down the groups to[/color][/color]
> which[color=green][color=darkred]
> > > you
> > > > > > posts).
> > > > > > --
> > > > > > Patrice
> > > > > >
> > > > > > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message[/color][/color][/color]
de[color=blue][color=green][color=darkred]
> > > > > > news:ekI$dC4kFHA.1412@TK2MSFTNGP09.phx.gbl...
> > > > > > > Hi,
> > > > > > >
> > > > > > > I have an inherited DataGrid, that does lots of extra stuff.[/color][/color][/color]
For[color=blue][color=green][color=darkred]
> > > > exemple
> > > > > > > drawing a backgroundimage in every cell. The problem is that[/color][/color]
> it's[color=green][color=darkred]
> > > > taking
> > > > > > too
> > > > > > > much time (using gdi+), so I want to do it using DirectX. I
> > > downloaded
> > > > > > > already the DSK etc, but I can't find how I need to draw an[/color][/color]
> image[color=green]
> > on[color=darkred]
> > > a
> > > > > > given
> > > > > > > position. I don't need stuff to write advanced 3D-games, just
> > > painting
> > > > > > that
> > > > > > > image. Can anybody help me with this? I'm already looking for[/color][/color]
> this[color=green][color=darkred]
> > > the
> > > > > > whole
> > > > > > > afternoon :-/
> > > > > > >
> > > > > > > I learned already that I shouldn't use DirectDraw (not[/color][/color][/color]
supported[color=blue][color=green][color=darkred]
> > > > > anymore)
> > > > > > > but Direct3D? But that's really all I know yet.
> > > > > > >
> > > > > > > Basicly I jsut need to be able to draw an imahe (jpg, bitmap)[/color][/color][/color]
on[color=blue]
> a[color=green][color=darkred]
> > > > Form
> > > > > in
> > > > > > > VB.NET: as simple and as fast as possible.. :-)
> > > > > > >
> > > > > > > Thanks a lot in advance,
> > > > > > >
> > > > > > > Pieter
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: Draw an Image on my Form
Your description below is not quite consistent:[color=blue]
> I prerender my images: that speeded up things a lot.[/color]
[color=blue]
> I know i could get faster using DrawimageUnscaled, but because
> the cell's width etc changes I can't use it here.[/color]
You are missing a big optimization if your "prerendering" code does not also
prerender to the ultimate size you're going to display. Stretching
operations are very expensive--far more so that bpp changes--you must arrange
your code to minimize the number of calls to DrawImage() over the course of
scrolling, otherwise you haven't optimized fully. (Technically, calling
DrawImage() with the width/height of the bitmap will be the same performance
as DrawImageUnscaled(), so the whole idea is to avoid stretching (or
shrinking) the image during critical performance times.)
My other concern is with your statement:[color=blue]
> 1. Format32bppPArgb pixel format is not the correct choice for optimum
> performance;[/color]
As this will only increase performance if the user is running at 32bpp (and
not, say, 16bpp). Also, leaving Alpha information in the format seems
suspicious to me--it seems that would means DrawImage() has more work to do.
In any case, I believe the correct way to optimize this is to use:
bmp = new Bitmap(width, height, graphics)
Where graphics was created as a "screen compatible" graphics (e.g. the one
you get during a paint event). This will ensure the pixel format matches
what eventually will go on the screen. Note that this can get complicated
for multi-monitor support (as each monitor can run at a different pixel
depth), so sticking with PixelFormat.Format32bppRgb might be warranted to
avoid these issues.
A final note: Never use the ImageAttribute parameter to DrawImage() (unless,
of course, you absolutely must), as this will massively slow things down.
I have done this quite successfully for a grid of picture thumbnails, and it
scrolls lightning fast. In my case, images that were not yet pre-rendered
got a place-holder image until a worker thread generated a thumbnail. This
entirely removes the slow stretch operation from the painting code, which is
always a good thing to do.
--Chris Fraley
"DraguVaso" wrote:[color=blue]
> I prerender my images: that speeded up things a lot.
> I put al my images into the Format32bppPArgb-Pixelformat
> I use double buffering
> I also use
> g.InterpolationMode = Drawing2D.InterpolationMode.NearestNeighbor
> g.CompositingQuality = Drawing2D.CompositingQuality.HighSpeed
> g.SmoothingMode = Drawing2D.SmoothingMode.HighSpeed
> I don't paint a BackGround to gain time.
>
> I used a code profiler to determine the bottlenecks and speed up several
> things. the only thing that still takes much time is the method which is
> actually painting every time the image: "g.DrawImage(fe.BackgroundImage,
> rectB)". I know i could get faster using DrawimageUnscaled, but because ot
> he cell's width etc changes I can't use it here.
>
> So I really think there isn't any more room left to make other improvements.
> So that's why i really would like to know how I have to paint an image with
> DirectX. Is this really such a hard question? Just painting an image with
> DirectX?[/color] | | | | re: Draw an Image on my Form
Hi,
Thanks a lot for the great explication and nice hints!
For the moment I'm using an event for each Cell to define the parameters of
it (background image, forgroundimage etc). But I guess that I will gain the
most in speed when using 1 default image for each column, that I resize on
every column-resize?
Just one question: How did you do the stuff with the place-holder image and
the worker thread-stuff?? It seems quit interesting to me. Is there a
possiblity to knwo which image is not yet prerendered? And how does the
prerendering principe acutally works?
Thanks,
Pieter
"Chris Fraley" <Chris Fraley@discussions.microsoft.com> wrote in message
news:4A0897BF-9E6C-4CCB-943F-BEFB6FD76AE8@microsoft.com...[color=blue]
> Your description below is not quite consistent:[color=green]
> > I prerender my images: that speeded up things a lot.[/color]
>[color=green]
> > I know i could get faster using DrawimageUnscaled, but because
> > the cell's width etc changes I can't use it here.[/color]
>
> You are missing a big optimization if your "prerendering" code does not[/color]
also[color=blue]
> prerender to the ultimate size you're going to display. Stretching
> operations are very expensive--far more so that bpp changes--you must[/color]
arrange[color=blue]
> your code to minimize the number of calls to DrawImage() over the course[/color]
of[color=blue]
> scrolling, otherwise you haven't optimized fully. (Technically, calling
> DrawImage() with the width/height of the bitmap will be the same[/color]
performance[color=blue]
> as DrawImageUnscaled(), so the whole idea is to avoid stretching (or
> shrinking) the image during critical performance times.)
>
> My other concern is with your statement:[color=green]
> > 1. Format32bppPArgb pixel format is not the correct choice for optimum
> > performance;[/color]
> As this will only increase performance if the user is running at 32bpp[/color]
(and[color=blue]
> not, say, 16bpp). Also, leaving Alpha information in the format seems
> suspicious to me--it seems that would means DrawImage() has more work to[/color]
do.[color=blue]
> In any case, I believe the correct way to optimize this is to use:
> bmp = new Bitmap(width, height, graphics)
> Where graphics was created as a "screen compatible" graphics (e.g. the one
> you get during a paint event). This will ensure the pixel format matches
> what eventually will go on the screen. Note that this can get complicated
> for multi-monitor support (as each monitor can run at a different pixel
> depth), so sticking with PixelFormat.Format32bppRgb might be warranted to
> avoid these issues.
>
> A final note: Never use the ImageAttribute parameter to DrawImage()[/color]
(unless,[color=blue]
> of course, you absolutely must), as this will massively slow things down.
>
> I have done this quite successfully for a grid of picture thumbnails, and[/color]
it[color=blue]
> scrolls lightning fast. In my case, images that were not yet pre-rendered
> got a place-holder image until a worker thread generated a thumbnail.[/color]
This[color=blue]
> entirely removes the slow stretch operation from the painting code, which[/color]
is[color=blue]
> always a good thing to do.
>
> --Chris Fraley
>
> "DraguVaso" wrote:[color=green]
> > I prerender my images: that speeded up things a lot.
> > I put al my images into the Format32bppPArgb-Pixelformat
> > I use double buffering
> > I also use
> > g.InterpolationMode = Drawing2D.InterpolationMode.NearestNeighbor
> > g.CompositingQuality = Drawing2D.CompositingQuality.HighSpeed
> > g.SmoothingMode = Drawing2D.SmoothingMode.HighSpeed
> > I don't paint a BackGround to gain time.
> >
> > I used a code profiler to determine the bottlenecks and speed up several
> > things. the only thing that still takes much time is the method which is
> > actually painting every time the image: "g.DrawImage(fe.BackgroundImage,
> > rectB)". I know i could get faster using DrawimageUnscaled, but because[/color][/color]
ot[color=blue][color=green]
> > he cell's width etc changes I can't use it here.
> >
> > So I really think there isn't any more room left to make other[/color][/color]
improvements.[color=blue][color=green]
> > So that's why i really would like to know how I have to paint an image[/color][/color]
with[color=blue][color=green]
> > DirectX. Is this really such a hard question? Just painting an image[/color][/color]
with[color=blue][color=green]
> > DirectX?[/color]
>[/color] | | | | re: Draw an Image on my Form
What is the layout ? "One image for each cell" would means you have really a
distinct image in each cell ? Or do you meant this is the same image or
several images based on some kind of criteria.
In case your design is to use the same picture in several cells, you could
see if you could create a scaled version of the image and use it for all
cells that have the same width/height (which is likely if you paint the same
images in all columns).
Before doing something as radical as an API change, you could for example
try to write a test application that really draws those bitmaps in a fully
optimized way (ie. scaled, no format change when blitting etc...). It should
give you an idea of how fast you can go. You'll then sacrifice a bit of time
to create those optimal conditions...
Good luck.
--
Patrice
"DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
news:eHOqpHnlFHA.4000@TK2MSFTNGP12.phx.gbl...[color=blue]
> I'm trying to use the TextureBrush, but it doesn't give the effect Iwant[/color]
it[color=blue]
> to have: it doesn't put in every cell 1 image, but puts the image x times
> next to each other, independent of the cell-sizes... What I need is: one
> image for each cell, and the image should be adapted to the cell-size... I
> tried with the Wrapmode.Clamp, but that just draws the image only one[/color]
time:[color=blue]
> in the left upper corner of my DataGrid... :-/
>
> "Patrice" <nobody@nowhere.com> wrote in message
> news:%23L3JxLDlFHA.2472@TK2MSFTNGP15.phx.gbl...[color=green]
> > See the TexturedBrush class. A brush is used to "fill in" something. It[/color]
> can[color=green]
> > be a "solid" color but also an image. See it as a kind of wallpaper[/color][/color]
(sorry[color=blue][color=green]
> > for my poor English).
> > So you want to render in each cell a different bitmap ? Each bitmap is
> > stretched to fit in the cell ?
> >
> > I'm not sure what is the graphics aspect you want but you could also see[/color]
> if[color=green]
> > a new strategy could help such as grabbing the datagrid as a bitmap and
> > combining it as a whole with perhaps a transparent color.
> >
> > Using DirectX is IMO a bit risky for such an application as it will
> > introduce a new dependency (for example if the target platform doesn't[/color]
> have[color=green]
> > DX9 installed it won't work) plus the result will depend on the hardware
> > support and finally you'll have likely some problems as you'll likely[/color][/color]
have[color=blue][color=green]
> > to combine GDI/DirectX.
> >
> > As a whole it doesn't seem to me that such a requirement should trigger[/color]
> the[color=green]
> > use of DirectX. If you really want to go this route, you could perhaps[/color][/color]
try[color=blue][color=green]
> > to render a stretched bitmap "cells" time at an arbitrary location. It
> > should already give you the maximum improvment you could get over using
> > GDI+.
> >
> > Good luck.
> > --
> > Patrice
> >
> > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> > news:%23VEIkRClFHA.3656@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > > I don't get it really: How can I use a Brush it I want to paint an[/color][/color]
> image?[color=green]
> > I[color=darkred]
> > > thought a Brush is jsut one color, not an image? Or am I wrong?
> > >
> > >
> > > "Patrice" <nobody@nowhere.com> wrote in message
> > > news:emegHM5kFHA.2920@TK2MSFTNGP14.phx.gbl...
> > > > What method are you using ? Using a brush seems quite quick...
> > > > (narrowed down to
> > > >
> > >[/color]
> >[/color]
>[/color]
microsoft.public.dotnet.framework,microsoft.public .dotnet.framework.drawing,[color=blue][color=green][color=darkred]
> > > > microsoft.public.dotnet.general)
> > > >
> > > >
> > > > --
> > > > Patrice
> > > >
> > > > "Patrice" <nobody@nowhere.com> a écrit dans le message de
> > > > news:O80zN%234kFHA.576@tk2msftngp13.phx.gbl...
> > > > > I meant not as a whole but broken into steps. How much time does[/color][/color][/color]
it[color=blue][color=green]
> > take[color=darkred]
> > > > to
> > > > > render how many cells ? What if you try to render a bitmap the[/color][/color][/color]
same[color=blue][color=green][color=darkred]
> > > number
> > > > > of times ? Especially keep ind mind that there are some subtles[/color][/color]
> things[color=green][color=darkred]
> > > > that
> > > > > could slow down the process such as stretching or doing some[/color]
> > operations[color=darkred]
> > > > each
> > > > > time you draw a cell rather than once etc...
> > > > >
> > > > > You could also see if alternate approaches may help such as[/color][/color][/color]
drawing[color=blue][color=green]
> > the[color=darkred]
> > > > > datagrid as a bitmap with a transparent color on a backgrround[/color][/color]
> bitmap.[color=green][color=darkred]
> > > > >
> > > > > DirectX is a low level API to discuss with graphics hardware and[/color]
> > doesn't[color=darkred]
> > > > > provide any GDI integration. IMO would be much more complex and I[/color]
> > still[color=darkred]
> > > > > suspect you have room left for improvments...
> > > > >
> > > > > --
> > > > >
> > > > > Patrice
> > > > >
> > > > > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> > > > > news:eyyxiT4kFHA.3936@TK2MSFTNGP10.phx.gbl...
> > > > > > Well that's exactly what made me decide which to use DirectX:[/color][/color][/color]
for[color=blue][color=green][color=darkred]
> > > every
> > > > > cell
> > > > > > it has to paint an image, and this has to happen on every paint[/color][/color][/color]
of[color=blue][color=green]
> > my[color=darkred]
> > > > > > datagrid. So everytilme somebody scrolls, clicks in it, etc. I[/color][/color]
> timed[color=green][color=darkred]
> > > it,
> > > > > and
> > > > > > it takes the most time of my whole application (after using my
> > > > application
> > > > > > for some seconds it has painted the same hing already more tahn[/color][/color]
> 4000[color=green][color=darkred]
> > > > > > times...) ! I'm trying to make it faster tha past days, and[/color][/color]
> imrpoved[color=green][color=darkred]
> > > it
> > > > > > already a lot, but I saw the only improvement i can make now is[/color]
> > using[color=darkred]
> > > > > > DirectX...
> > > > > >
> > > > > >
> > > > > > "Patrice" <nobody@nowhere.com> wrote in message
> > > > > > news:eRIXDK4kFHA.3568@tk2msftngp13.phx.gbl...
> > > > > > > Have you timed to find out what the problem is ? DirectX would[/color]
> > more[color=darkred]
> > > > > likely
> > > > > > > help if you repeateadly draw the whole (updated) thing. Here[/color][/color]
> you[color=green][color=darkred]
> > > just
> > > > > > have
> > > > > > > to draw this one time before there is some other kind of
> > > interaction.
> > > > > > >
> > > > > > > Before switching to a whole new method I would investigate (in
> > > > > particular
> > > > > > I
> > > > > > > would time) the current code to find out where is spent the[/color][/color][/color]
time[color=blue][color=green][color=darkred]
> > > > > budget...
> > > > > > >
> > > > > > > (and next time thanks for trying to narrow down the groups to[/color]
> > which[color=darkred]
> > > > you
> > > > > > > posts).
> > > > > > > --
> > > > > > > Patrice
> > > > > > >
> > > > > > > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message[/color][/color]
> de[color=green][color=darkred]
> > > > > > > news:ekI$dC4kFHA.1412@TK2MSFTNGP09.phx.gbl...
> > > > > > > > Hi,
> > > > > > > >
> > > > > > > > I have an inherited DataGrid, that does lots of extra stuff.[/color][/color]
> For[color=green][color=darkred]
> > > > > exemple
> > > > > > > > drawing a backgroundimage in every cell. The problem is that[/color]
> > it's[color=darkred]
> > > > > taking
> > > > > > > too
> > > > > > > > much time (using gdi+), so I want to do it using DirectX. I
> > > > downloaded
> > > > > > > > already the DSK etc, but I can't find how I need to draw an[/color]
> > image[color=darkred]
> > > on
> > > > a
> > > > > > > given
> > > > > > > > position. I don't need stuff to write advanced 3D-games,[/color][/color][/color]
just[color=blue][color=green][color=darkred]
> > > > painting
> > > > > > > that
> > > > > > > > image. Can anybody help me with this? I'm already looking[/color][/color][/color]
for[color=blue][color=green]
> > this[color=darkred]
> > > > the
> > > > > > > whole
> > > > > > > > afternoon :-/
> > > > > > > >
> > > > > > > > I learned already that I shouldn't use DirectDraw (not[/color][/color]
> supported[color=green][color=darkred]
> > > > > > anymore)
> > > > > > > > but Direct3D? But that's really all I know yet.
> > > > > > > >
> > > > > > > > Basicly I jsut need to be able to draw an imahe (jpg,[/color][/color][/color]
bitmap)[color=blue]
> on[color=green]
> > a[color=darkred]
> > > > > Form
> > > > > > in
> > > > > > > > VB.NET: as simple and as fast as possible.. :-)
> > > > > > > >
> > > > > > > > Thanks a lot in advance,
> > > > > > > >
> > > > > > > > Pieter
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: Draw an Image on my Form
I meant fully optimized even if not applicable in the real app. The goal is
to have an idea about the highest level of performance and to see if the
real app is close.
--
"Patrice" <nobody@nowhere.com> a écrit dans le message de
news:u%23jGYyCmFHA.1444@TK2MSFTNGP10.phx.gbl...[color=blue]
> What is the layout ? "One image for each cell" would means you have really[/color]
a[color=blue]
> distinct image in each cell ? Or do you meant this is the same image or
> several images based on some kind of criteria.
>
> In case your design is to use the same picture in several cells, you could
> see if you could create a scaled version of the image and use it for all
> cells that have the same width/height (which is likely if you paint the[/color]
same[color=blue]
> images in all columns).
>
> Before doing something as radical as an API change, you could for example
> try to write a test application that really draws those bitmaps in a fully
> optimized way (ie. scaled, no format change when blitting etc...). It[/color]
should[color=blue]
> give you an idea of how fast you can go. You'll then sacrifice a bit of[/color]
time[color=blue]
> to create those optimal conditions...
>
> Good luck.
> --
> Patrice
>
> "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> news:eHOqpHnlFHA.4000@TK2MSFTNGP12.phx.gbl...[color=green]
> > I'm trying to use the TextureBrush, but it doesn't give the effect Iwant[/color]
> it[color=green]
> > to have: it doesn't put in every cell 1 image, but puts the image x[/color][/color]
times[color=blue][color=green]
> > next to each other, independent of the cell-sizes... What I need is: one
> > image for each cell, and the image should be adapted to the cell-size...[/color][/color]
I[color=blue][color=green]
> > tried with the Wrapmode.Clamp, but that just draws the image only one[/color]
> time:[color=green]
> > in the left upper corner of my DataGrid... :-/
> >
> > "Patrice" <nobody@nowhere.com> wrote in message
> > news:%23L3JxLDlFHA.2472@TK2MSFTNGP15.phx.gbl...[color=darkred]
> > > See the TexturedBrush class. A brush is used to "fill in" something.[/color][/color][/color]
It[color=blue][color=green]
> > can[color=darkred]
> > > be a "solid" color but also an image. See it as a kind of wallpaper[/color][/color]
> (sorry[color=green][color=darkred]
> > > for my poor English).
> > > So you want to render in each cell a different bitmap ? Each bitmap is
> > > stretched to fit in the cell ?
> > >
> > > I'm not sure what is the graphics aspect you want but you could also[/color][/color][/color]
see[color=blue][color=green]
> > if[color=darkred]
> > > a new strategy could help such as grabbing the datagrid as a bitmap[/color][/color][/color]
and[color=blue][color=green][color=darkred]
> > > combining it as a whole with perhaps a transparent color.
> > >
> > > Using DirectX is IMO a bit risky for such an application as it will
> > > introduce a new dependency (for example if the target platform doesn't[/color]
> > have[color=darkred]
> > > DX9 installed it won't work) plus the result will depend on the[/color][/color][/color]
hardware[color=blue][color=green][color=darkred]
> > > support and finally you'll have likely some problems as you'll likely[/color][/color]
> have[color=green][color=darkred]
> > > to combine GDI/DirectX.
> > >
> > > As a whole it doesn't seem to me that such a requirement should[/color][/color][/color]
trigger[color=blue][color=green]
> > the[color=darkred]
> > > use of DirectX. If you really want to go this route, you could perhaps[/color][/color]
> try[color=green][color=darkred]
> > > to render a stretched bitmap "cells" time at an arbitrary location. It
> > > should already give you the maximum improvment you could get over[/color][/color][/color]
using[color=blue][color=green][color=darkred]
> > > GDI+.
> > >
> > > Good luck.
> > > --
> > > Patrice
> > >
> > > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message de
> > > news:%23VEIkRClFHA.3656@TK2MSFTNGP09.phx.gbl...
> > > > I don't get it really: How can I use a Brush it I want to paint an[/color]
> > image?[color=darkred]
> > > I
> > > > thought a Brush is jsut one color, not an image? Or am I wrong?
> > > >
> > > >
> > > > "Patrice" <nobody@nowhere.com> wrote in message
> > > > news:emegHM5kFHA.2920@TK2MSFTNGP14.phx.gbl...
> > > > > What method are you using ? Using a brush seems quite quick...
> > > > > (narrowed down to
> > > > >
> > > >
> > >[/color]
> >[/color]
>[/color]
microsoft.public.dotnet.framework,microsoft.public .dotnet.framework.drawing,[color=blue][color=green][color=darkred]
> > > > > microsoft.public.dotnet.general)
> > > > >
> > > > >
> > > > > --
> > > > > Patrice
> > > > >
> > > > > "Patrice" <nobody@nowhere.com> a écrit dans le message de
> > > > > news:O80zN%234kFHA.576@tk2msftngp13.phx.gbl...
> > > > > > I meant not as a whole but broken into steps. How much time does[/color][/color]
> it[color=green][color=darkred]
> > > take
> > > > > to
> > > > > > render how many cells ? What if you try to render a bitmap the[/color][/color]
> same[color=green][color=darkred]
> > > > number
> > > > > > of times ? Especially keep ind mind that there are some subtles[/color]
> > things[color=darkred]
> > > > > that
> > > > > > could slow down the process such as stretching or doing some
> > > operations
> > > > > each
> > > > > > time you draw a cell rather than once etc...
> > > > > >
> > > > > > You could also see if alternate approaches may help such as[/color][/color]
> drawing[color=green][color=darkred]
> > > the
> > > > > > datagrid as a bitmap with a transparent color on a backgrround[/color]
> > bitmap.[color=darkred]
> > > > > >
> > > > > > DirectX is a low level API to discuss with graphics hardware and
> > > doesn't
> > > > > > provide any GDI integration. IMO would be much more complex and[/color][/color][/color]
I[color=blue][color=green][color=darkred]
> > > still
> > > > > > suspect you have room left for improvments...
> > > > > >
> > > > > > --
> > > > > >
> > > > > > Patrice
> > > > > >
> > > > > > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le message[/color][/color][/color]
de[color=blue][color=green][color=darkred]
> > > > > > news:eyyxiT4kFHA.3936@TK2MSFTNGP10.phx.gbl...
> > > > > > > Well that's exactly what made me decide which to use DirectX:[/color][/color]
> for[color=green][color=darkred]
> > > > every
> > > > > > cell
> > > > > > > it has to paint an image, and this has to happen on every[/color][/color][/color]
paint[color=blue]
> of[color=green][color=darkred]
> > > my
> > > > > > > datagrid. So everytilme somebody scrolls, clicks in it, etc. I[/color]
> > timed[color=darkred]
> > > > it,
> > > > > > and
> > > > > > > it takes the most time of my whole application (after using my
> > > > > application
> > > > > > > for some seconds it has painted the same hing already more[/color][/color][/color]
tahn[color=blue][color=green]
> > 4000[color=darkred]
> > > > > > > times...) ! I'm trying to make it faster tha past days, and[/color]
> > imrpoved[color=darkred]
> > > > it
> > > > > > > already a lot, but I saw the only improvement i can make now[/color][/color][/color]
is[color=blue][color=green][color=darkred]
> > > using
> > > > > > > DirectX...
> > > > > > >
> > > > > > >
> > > > > > > "Patrice" <nobody@nowhere.com> wrote in message
> > > > > > > news:eRIXDK4kFHA.3568@tk2msftngp13.phx.gbl...
> > > > > > > > Have you timed to find out what the problem is ? DirectX[/color][/color][/color]
would[color=blue][color=green][color=darkred]
> > > more
> > > > > > likely
> > > > > > > > help if you repeateadly draw the whole (updated) thing.[/color][/color][/color]
Here[color=blue][color=green]
> > you[color=darkred]
> > > > just
> > > > > > > have
> > > > > > > > to draw this one time before there is some other kind of
> > > > interaction.
> > > > > > > >
> > > > > > > > Before switching to a whole new method I would investigate[/color][/color][/color]
(in[color=blue][color=green][color=darkred]
> > > > > > particular
> > > > > > > I
> > > > > > > > would time) the current code to find out where is spent the[/color][/color]
> time[color=green][color=darkred]
> > > > > > budget...
> > > > > > > >
> > > > > > > > (and next time thanks for trying to narrow down the groups[/color][/color][/color]
to[color=blue][color=green][color=darkred]
> > > which
> > > > > you
> > > > > > > > posts).
> > > > > > > > --
> > > > > > > > Patrice
> > > > > > > >
> > > > > > > > "DraguVaso" <pietercoucke@hotmail.com> a écrit dans le[/color][/color][/color]
message[color=blue][color=green]
> > de[color=darkred]
> > > > > > > > news:ekI$dC4kFHA.1412@TK2MSFTNGP09.phx.gbl...
> > > > > > > > > Hi,
> > > > > > > > >
> > > > > > > > > I have an inherited DataGrid, that does lots of extra[/color][/color][/color]
stuff.[color=blue][color=green]
> > For[color=darkred]
> > > > > > exemple
> > > > > > > > > drawing a backgroundimage in every cell. The problem is[/color][/color][/color]
that[color=blue][color=green][color=darkred]
> > > it's
> > > > > > taking
> > > > > > > > too
> > > > > > > > > much time (using gdi+), so I want to do it using DirectX.[/color][/color][/color]
I[color=blue][color=green][color=darkred]
> > > > > downloaded
> > > > > > > > > already the DSK etc, but I can't find how I need to draw[/color][/color][/color]
an[color=blue][color=green][color=darkred]
> > > image
> > > > on
> > > > > a
> > > > > > > > given
> > > > > > > > > position. I don't need stuff to write advanced 3D-games,[/color][/color]
> just[color=green][color=darkred]
> > > > > painting
> > > > > > > > that
> > > > > > > > > image. Can anybody help me with this? I'm already looking[/color][/color]
> for[color=green][color=darkred]
> > > this
> > > > > the
> > > > > > > > whole
> > > > > > > > > afternoon :-/
> > > > > > > > >
> > > > > > > > > I learned already that I shouldn't use DirectDraw (not[/color]
> > supported[color=darkred]
> > > > > > > anymore)
> > > > > > > > > but Direct3D? But that's really all I know yet.
> > > > > > > > >
> > > > > > > > > Basicly I jsut need to be able to draw an imahe (jpg,[/color][/color]
> bitmap)[color=green]
> > on[color=darkred]
> > > a
> > > > > > Form
> > > > > > > in
> > > > > > > > > VB.NET: as simple and as fast as possible.. :-)
> > > > > > > > >
> > > > > > > > > Thanks a lot in advance,
> > > > > > > > >
> > > > > > > > > Pieter
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: Draw an Image on my Form
Hello:
I have taken three images of type gif. i am not able to get the transparency
as well as rotation. and also i need the grouping of the images. I need some
sample code to solve this problem as i am new to this field.
i am using the following code for transparency.
Color col = bm.GetPixel( 1, 1 );
picRT.Region = BitmapToRegion.Convert( bm, col,
TransparencyMode.ColorKeyTransparent);
But if i use this code i am not getting rotation. i will be thankful if u
help in regards
Dhanunjay | | | | re: Draw an Image on my Form
Hello:
I have taken three images of type gif. i am not able to get the transparency
as well as rotation. and also i need the grouping of the images. I need some
sample code to solve this problem as i am new to this field.
i am using the following code for transparency.
Color col = bm.GetPixel( 1, 1 );
picRT.Region = BitmapToRegion.Convert( bm, col,
TransparencyMode.ColorKeyTransparent);
But if i use this code i am not getting rotation. i will be thankful if u
help in regards
Dhanunjay | | | | re: Draw an Image on my Form
Hello:
I have taken three images of type gif. i am not able to get the transparency
as well as rotation. and also i need the grouping of the images. I need some
sample code to solve this problem as i am new to this field.
i am using the following code for transparency.
Color col = bm.GetPixel( 1, 1 );
picRT.Region = BitmapToRegion.Convert( bm, col,
TransparencyMode.ColorKeyTransparent);
But if i use this code i am not getting rotation. i will be thankful if u
help in regards
Dhanunjay |  | Similar .NET Framework bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,327 network members.
|