I'm trying to draw a 400x400 px image to a 400x400 form that I made. What I'm doing is:
Graphics.DrawImage Method (Image, 0, 0, 400, 400) 0, 0, 400, 400, ...
But when I run the form, the image seems to stretch slightly upon the y-axis, the x-axis seems to be working correctly.
This was what I was doing before (stretching the old smaller images to fit the size)
... (Image, 0, 0, 264, 231) 0, 0, 400, 400, ...
or something like that. Now that I'm trying to do it the correct way, I can't seem to get it to work properly.
Edit: I wonder if using a simpler verson of Graphics.DrawImage would work? Although I still need to figure out what is wrong with what I'm doing.
Thanks in advance.
If you have a borderless form at 400 x 400, then it should be ok.
If not, then you have to account for the non-client dimensions of the form to reach the size you want.
You can just do this for drawing:
e.Graphics.DrawImage(image, 0, 0)
To set your form size, you can try this:
Me.ClientSize = New Size(400, 400)
Related
I have an EncodedImage. I want to draw a FontImage over it to get another EncodedImage. It’s similar to a LayeredLayout (a layer over another layer), but in this case I need a new EncodedImage with the two images merged.
Thank you
Use a mutable image.
Image img = Image.create(encImage.getWidth(), encImage.getHeight(), 0);
Graphics g = img.getGraphics();
g.drawImage(encImage, 0, 0);
g.drawImage(fontImage.scaled(encImage.getWidth(), encImage.getHeight()).toImage(), 0, 0);
XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);
renderer.setOrientation(Orientation.HORIZONTAL);
setChartSettings(renderer, "Monthly sales in the last 1 years", "Cars", "sold", 0, 5, 0, 100, ColorUtil.GRAY, ColorUtil.LTGRAY);
renderer.setXLabels(1);
renderer.setYLabels(5);
renderer.setBarWidth(40);
renderer.setLabelsTextSize(8.0f);
Label text size is not rendering in Bar Charts?
You are setting the text size to 8 pixels which will make it pretty small and might not work if your fonts aren't native fonts. Try something like this.
renderer.setLabelsTextFont(Font.createTrueTypeFont("native:MainThin", "native:MainThin"));
renderer.setLabelsTextSize(convertToPixels(5));
I am developing a small tool. I want to draw a geometry where I have already used stencil. How do I do that?
// drawing stencil
glEnable(GL_STENCIL_TEST);
glColorMask(false, false, false, false);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
glStencilFunc(GL_EQUAL, 0, 1);
// drawing geometry
glColorMask(true, true, true, true);
glStencilFunc(GL_ALWAYS, 0, 1);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
glDisable(GL_STENCIL_TEST);
Well, if you want to draw your geometry stenciled out, then you need the stencil test enabled for that, not disabled. But you disable stencil testing in the very last line of code you posted.
How to take all screenshot from Panel in mono C# ?
I need not used winAPI.
My panel can not be fully visible.
Your question is not exactly clear but in case you meant taking a screenshot of the desktop: below is a small example of how you could do this using gtk:
using Gtk;
...
Gdk.Window window = Gdk.Global.DefaultRootWindow;
if (window!=null)
{
Gdk.Pixbuf pixBuf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8,
window.Screen.Width, window.Screen.Height);
pixBuf.GetFromDrawable(window, Gdk.Colormap.System, 0, 0, 0, 0,
window.Screen.Width, window.Screen.Height);
pixBuf.ScaleSimple(400, 300, Gdk.InterpType.Bilinear);
pixBuf.Save("screenshot0.jpeg", "jpeg");
}
hope this helps, regards
I need to resize and crop to exactly 60x80px from various size and
aspect ratio. Just before i put into Datastore. Anyone already got
this issue resolved.
Currently i already succed to just transform it to exact height (80px)
with various width which nott look so good when i try to display it on
a list. e.g jcaroussel.
My db.put code is like bellow:
if users.get_current_user():
personal.personal_id = int(self.request.get('personal_id'))
personal.name = self.request.get('name')
personal.latitude = self.request.get('latitude')
personal.info = self.request.get('info')
photo = images.resize(self.request.get('img'), 0, 80)
personal.photo = db.Blob(photo)
personal.lc_id = int(self.request.get('lc_id'))
personal.put()
self.redirect('/admin/personal')
else:
self.response.out.write('I\'m sorry, you don\'t have permission to add this LP Personal Data.')
I just want to do similar result when we upload our avatar on google
talk/google chat.
Anyone solved this?
Thx
After your resize your image down to 80 pixels in height, you would have to use the crop function as defined here. For example:
img = images.Image(self.request.get('img'))
img.resize(0, 80)
resized_img = img.execute_transforms(output_encoding=images.JPEG)
left_x = (resized_img.width - 60) / 2
resized_img.crop(left_x, 0, left_x + 60, 80)
cropped_img = resized_image.execute_transforms(output_encoding=images.JPEG)
In my example it crops to the center of the image.
It assumes that the resized image is at least 60 pixels wide, but obviously you would have to add some checks to confirm this, because a user might not upload an image in the right size.
I used something else:
Resize the original image to your max height (80)
Store the resized (but complete/not cropped) image
Display it inside a <div> that has the following CSS: width: 60px; height: 80px; overflow: hidden;
That way it will show nicely in your list, but you can still display the complete resized picture on your user's profile page (looking at you code I imagine that's what you are trying to do, right?)