i am trying to use glass magnifier on PictureEdit(devexpress) control in windows form
we have set PictureEdit.SizeMode =Squeeze . its important. in our application i am already using Squeeze size mode.
i am getting problem of calculation of mouse location , for draw rect image onto enalged panel.
here is code of PartialMag_Paint event of enalaged panel. in which we show zoomed imaged of mouse pointed area
int srcx = (PartailMagImageView.Location.X + PartailMagImageView.Width / 2);
int srcy = (PartailMagImageView.Location.Y + PartailMagImageView.Height / 2);
e.Graphics.DrawImage(this.Image
, new System.Drawing.Rectangle(0, 0, PartailMagImageView.Width, PartailMagImageView.Height)
, new System.Drawing.Rectangle(srcx - ZoomOutRate / 2, srcy - ZoomOutRate / 2, ZoomOutRate, ZoomOutRate)
, GraphicsUnit.Pixel);
Pen mypen = new Pen(Color.Black, 7);
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
e.Graphics.DrawEllipse(mypen, 0, 0, PartailMagImageView.Width - 7, PartailMagImageView.Height - 7);
if any one need to see complete code sample. i am attaching sample in dropbox link
https://www.dropbox.com/s/mogmshuiimtvhk7/ImageMagnifyingWindowsForm.zip?dl=0
PictureEdit has the ViewportToImage and ImageToViewport methods allowing you to convert viewport coordinates to the source image coordinates and vice versa.
Related
I've a simply box as follows:
BoxVisual3D box = new BoxVisual3D();
box.Width = Convert(panel.Width);
box.Length = Convert(panel.Length);
box.Height = Convert(panel.Thickness);
box.Center = new Point3D(quotaX, quotaY, quotaH);
string matType = panel.Material == SvBaseboardMaterial.MDF ? "mv-pannello-mdf.jpg" : "mv-pannello-base.jpg";
box.Material = MaterialHelper.CreateImageMaterial(new BitmapImage(new Uri(#"" + matType, UriKind.Relative)), 1, false);
viewport.Children.Add(box);
I would like to apply different texture on each side of the box. Any hints? there're lack of information on the project site
You need to use TextureCoordinates on each side of your cube to sample different part of your image.
I have the following png:
Each Icon is 100X100 px. All in all 800X100 px.
I have the following ImageView xml:
<ImageView
android:id="#+id/CycleStageImage"
android:layout_width="100dp"
android:layout_height="100dp">
I would like to set CycleStageImage to be show different Icon (100,100) on Timer Interval of 1 Second back and forth.
I am having a problem generating a code that moves on Axis of this PNG.
I have tried the followings from multiple links over SOF, but with no luck:
//first try - not working
//Resources res = mainActivity.ApplicationContext.Resources;
//Bitmap bitmap = BitmapFactory.DecodeResource(res, Resource.Id.CycleImage);
//BitmapDrawable bitmapDrawable = new BitmapDrawable(Resources.System, bitmap);
//ClipDrawable clipDrawable = new ClipDrawable(bitmapDrawable, GravityFlags.Center, ClipDrawable.Horizontal);
//clipDrawable.SetBounds(100, 100, 100, 100);
//clipDrawable.SetLevel(100);
//imageView.SetImageResource(Android.Resource.Color.Transparent);
//imageView.SetImageDrawable(clipDrawable);
//second try - shows only part of the left top corner
//double TUNNING = 0.5; //0.5 cut in half
//Bitmap srcBmp = BitmapFactory.DecodeResource(Resources.System, cycleStage);
//Bitmap modBmp = Bitmap.CreateBitmap(
// srcBmp,
// 0,
// srcBmp.Height, // TUNNING
// srcBmp.Height,
// srcBmp.Height
// );
//third try - same as the second try.
//int START_X = 0;
//int START_Y = 100;
//int WIDTH_PX = 100;
//int HEIGHT_PX = 100;
//// Crop bitmap
//Bitmap newBitmap = Bitmap.CreateBitmap(SOURCE_BITMAP, START_X, START_Y, WIDTH_PX, HEIGHT_PX, null, false);
//// Assign new bitmap to ImageView
//imageView.SetImageBitmap(newBitmap);
I have followed the Android tutorial:
https://developer.android.com/guide/topics/resources/drawable-resource.html#Clip
but with no luck..
It would be much appreciated the help with timer as well with the png.
Thanks!
Finally I got it to work, following these steps:
(Although I admit its a bit lame...)
I divided the above PNG into 8 (100x100) PNGs each using online tool -> PNG Splitter
I created a GIF using online tool - GIF Maker -> http://gifmaker.me/
I have placed the saved gif under "Assets" folder and changed its properties-> build action to "AndroidAsset"
I have created WebView and placed it inside my XML screen. it looks like this:
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/MyWebView"
android:layout_width="100dp"
android:layout_height="100dp"/>
In my Activity I generated the code as follows:
WebView myWebView = (WebView)findViewById(Resource.Id.MyWebView);
myWebView.loadUrl("file:///android_asset/Gif.gif");
It works like a charm!
I hope it will be of assistant to anyone who desires to accomplish running GIF's inside android application.
Good Luck.
I have a canvas with a background image:
var bi = new BitmapImage(new Uri(imgLocFull));
var ib = new ImageBrush(bi) {Stretch = Stretch.UniformToFill};
MyCanvas.Background = ib;
I am overlaying various shapes on the image, and want the position of the shapes relative to the background image to be fixed.
If my application window is resized, the amount of the image that is cropped, horizontally and vertically, changes, and when my shapes are redrawn, they do not appear in the same position on the background image.
How can I determine how much of the image has been cropped (to apply an adjustment factor to the overlaid objects' positions?) Or is there a better way of fixing the location of a shape relative to the background image?
Here is my present drawing code:
var l = new Ellipse();
var scb = new SolidColorBrush();
scb.Color = Color.FromRgb(rCol, gCol, bCol);
l.Fill = scb;
l.StrokeThickness = 0;
l.Width = 3;
l.Height = 3;
Canvas.SetBottom(l, point.Y); // * clipping factor here?
Canvas.SetLeft(l, point.X); // * clipping factor here?
MyCanvas.Children.Add(l);
EDIT: Further Clarification
Here's a concrete example of what I am trying to achieve. My image is an aerial photograph, and I want to mark a particular geographical feature (with, say, an ellipse.)
When the window is resized, the ellipse doesn't stay on the feature, it stays relative to the left and top of the canvas.
I can get it closer to the right place by moving it using a factor (newx = newheight/oldheight * oldx) but this doesn't quite work because of the UniformToFill stretch mode, which sees some of the image clipped off the canvas.
The Top and Left of the Canvas are 'anchored', while the Bottom and Right move when resizing... try setting the Canvas.Top Attached Property instead, along with the Canvas.Left Attached Property as you are:
var l = new Ellipse();
var scb = new SolidColorBrush();
scb.Color = Color.FromRgb(rCol, gCol, bCol);
l.Fill = scb;
l.StrokeThickness = 0;
l.Width = 3;
l.Height = 3;
Canvas.SetTop(l, point.Y); // * clipping factor here?
Canvas.SetLeft(l, point.X); // * clipping factor here?
MyCanvas.Children.Add(l);
UPDATE >>>
You asked Or is there a better way of fixing the location of a shape relative to the background image?
I answered this question, so I don't understand why you would need to do anything else... your objects will not move when the screen in resized *if you only set the Grid.Top and Grid.Left properties.
In a dialog window's code-behond, I select icon size based on my application's font size the following way:
double iconSize = 24;
if (Session.FontSize <= 16)
iconSize = 48;
else if (Session.FontSize >= 28)
iconSize = 72;
Uri uri = new Uri("pack://application:,,,/MyApp;component/Resources/
Status-dialog-information.ico");
BitmapDecoder decoder = BitmapDecoder.Create(uri,
BitmapCreateOptions.DelayCreation,
BitmapCacheOption.Default);
BitmapSource bms = decoder.Frames.
Where(f => f.Width == iconSize).FirstOrDefault();
imageControl.Source = bms;
, where imageControl is, well, Image control. I use icons from Oxygen set (found in iconarchive.com)
Now, the above code works with some of the icons, with no problem.
But for some other icon files, such as the above, it works when I create my dialog window for the first time only. Second time I creat a dialog window BitmapDecoder.Create() method throws System.IO.FileFormatException - "The image format is unrecognized". Please suggest how to fix it.
Probably difficult to answer, without more details. I just created static field to initialize once.
I have a grid within a grid and i want the content of the second to move about without encroaching on the first grid.
Much like the panorama view but can move left or right as well as up and down.
I can get this working but unfortunately when you move down the top overflows into the outer grid overlapping any controls within it.
Is there a way to hide the overflow almost like CSS overflow:hidden?
Any help would be really appropriated.
Thank you
Andrew
Possible solution:
var gridWidth = (this.tilesize * (this.gridSize - 1)) / 2;
var top = -(((-offsetY + tileY) * this.tilesize) - gridWidth);
var left = -(((-offsetX + tileX) * this.tilesize) - gridWidth);
this.Container.Margin = new Thickness(left, top, 0, 0);
var clipSection = new RectangleGeometry();
clipSection.Rect = new Rect(-1 * left, -1 * top, 480, 400);
this.Container.Clip = clipSection;
this.Container.Dispatcher.BeginInvoke(new ThreadStart(delegate
{
this.Container.Clip = clipSection;
}));
You could do this by putting something in the cells of the "outer" grid and seeing a higher ZIndex than the elements you are moving around. The elements with the higher ZIndex appear above the lower ones.