Using a gradient

C

Crirus

The main ideea:
I havea 513x513 array of values....I draw a sort of map using that values
for colors... so I have a realistic lanscape (map).
I want to zoom about 60 times that map...and the zoomed area to be drawn on
full screen.

I want to draw it smoth not a square of 60 pixels x 60 pixels
with one color, because I can see blocks and it's not good.
There is a way to interpoate the colors between rectangles to show a smoth
zoom?

Crirus
 
N

Nak

Hi Cirus,
I want to draw it smoth not a square of 60 pixels x 60 pixels
with one color, because I can see blocks and it's not good.
There is a way to interpoate the colors between rectangles to show a smoth
zoom?

Change the interpolation mode of the graphics object that you are using to
scale the image...

Graphics.InterpolationMode = ...

You can select "High Quality Bilinear", this will give a good quality
smoothed finish when using the drawImage method of the graphics object.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
C

Crirus

I dint experienced yet, but can you tell me if the final zoomed image looks
like I do it in photoshop?
Because a 60 timese enlarge for a pixel is lot of zoom :)
Actualy I have a 513x513 map and need one image at tile level zoom
 
N

Nak

Hi Fergus,
Did you get my email (6:20 yesterday evening)?

Yup, email was recieved, but I could only reply today, did you get my reply?

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
J

Jay B. Harlow [MVP - Outlook]

Crirus,
Have you tried either a LinearGradientBrush or PathGradientBrush?

Both can be found in the System.Drawing.Drawing2D namespace.

A LinearGradientBrush transitions between two colors based on two parallel
lines.

A PathGradientBrush transitions between n colors based on m points.

Charles Petzold's book "Programming Microsoft Windows with Microsoft Visual
Basic .NET" from MS Press has a chapter were he discusses at length both
brushes with examples.

I don't have a clean example, I would consider a PathGradientBrush, where
the four corners of the square is the four points of the polygon used to
define the PathGradientBrush, I'm not sure where the center point for the
brush would be (the center of the square maybe). I think the colors for each
corner would be the color for that point (array value).

Alternatively have you looked at the Managed DirectX 9 SDK?

Hope this helps
Jay
 
N

Nak

Hi Cirus,
I dint experienced yet, but can you tell me if the final zoomed image looks
like I do it in photoshop?
Because a 60 timese enlarge for a pixel is lot of zoom :)
Actualy I have a 513x513 map and need one image at tile level zoom

If you test the various interpolation mode settings you can choose one that
looks best for you. Photoshop resizes using 3 different techniques, the 3
different techniques are employed by the .NET framework also, these 3
different techniques translate as

Bicubic = High quality bicubic
Bilinear = High quality bilinear
Nearest neighbour = Nearest neighbour

Take a look at the interpolationmode enumeration. Also if you go into
Photoshop and select "Image > Image Size" from the menu you will be
displayed with another dialog, at the bottom of the dialog is the selection
for the interpolation mode that Photoshop will use when resizing the image,
try all 3 types out to see their effects.

I hope this helps.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
C

Crirus

Well, I did tried that way photoshop interpolate...unfortunately the zoom
sems to be to high to have a nice result..too blury...
 
N

Nak

Hi there Cirrus,
I attached what I acieved so farr.. with a question
How can I interpolate a small area on say, perspectiveZoom of each tile with
the addiacent tile..
I whould like to make a smooth transition, but I dont want to extend the
interpolation to the center of neighboor tile, only a few pixels on each
border

If the built in interpolation modes do not work for you the only way I can
think of would be to attempt to implement your own. You would have to
create the initial image without interpolation using the nearestneighbour
interpolation mode, and then manipulate it manually to the desired degree.

Have you tried the other interpolation modes? If Photoshop couldn't do it
as you wanted then don't expect the .NET framework to! Photoshops graphical
powers are very high.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
J

Jay B. Harlow [MVP - Outlook]

Crirus,
If I am following your question: within the 60 x 60 tile, consider using a
gradient function along the border of each cell, where you are using a
border of say 10, my concern would be the corners...

I would consider making the corner itself between the tiles the center point
(not sure which color I would use) instead of the center of a tile as I was
originally thinking. So I would wind up with a + sign in each corner with
each leg about 20 wide...

Basically for two adjacent tiles, I would have three brushes, the first tile
which is 60 x 50, the middle 'tile/border' which is 60 x 20, then the second
tile which is 60 x 50, . The middle 'tile/border' would be the gradient
between the two tiles... Of course because we are actually taking four
adjacent tiles, there would be 9 brushes...

Note: I am just thinking out loud here, I have not actually done this or
tried this, hopefully you come up with an idea that works.

Hope this helps
Jay
 
N

Nak

Hi Jay,
Note: I am just thinking out loud here, I have not actually done this or
tried this, hopefully you come up with an idea that works.

Yeah, please share if you do Crirus, it would be interesting to see this
implemented and how much processing overheads are required.

Nick.

--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
"No matter. Whatever the outcome, you are changed."

Fergus - September 5th 2003
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
 
C

Crirus

Well, Jay you got the ideea... I was thinking on something similar, but I
still hope there is a Framework class that can interpolate a custom area
between 2 points not a gradient startig at one point and ending at the
other.
The ideea is to simulate the Photoshop gradient tool
The smaller gradient tool is dragged, the sharper the interpolation that
take place.
And if I dragg the gradient tool from one edge to the other of the canvas,
the interpolation is like GradientBrush do it here

Can I set a smaller interval to have the gradient executed?
 
J

Jay B. Harlow [MVP - Outlook]

Crirus,
Can you post the color data for say 25 tiles? (5 rows of 5 columns each). As
I understand that each tile is a single color, this would be 25 colors.

Then I can play with a couple of my ideas, and possible post a code snippet.
It would however be later today or this weekend before I got to it.

Unfortunately I do not use Photoshop itself.
Can I set a smaller interval to have the gradient executed?
Only in that you can define the size of the brush & you can define the size
of the tile you are drawing into. If you want a smaller interval I would
define the brush for a smaller part of the tile, and then only draw that
smaller part of the tile...

Hope this helps
Jay
 
C

Crirus

Colors have not a big inportance in this..you can pick up any 25 colors on
green and sand yellow theme.
Look at the pics attached in some prev messages under this topic
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top