Search Results

Search found 808 results on 33 pages for 'resizing'.

Page 6/33 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Image Resizing and Compression

    - by GSTAR
    Hi guys, I'm implementing an image upload facility for my website. The uploading facility is complete but what I'm working on at the moment is manipulating the images. For this task I am using PHPThumb (http://phpthumb.gxdlabs.com). Anyway as I go along I'm coming across potential issues, to do with resizing and compression. Basically I want to acheive the following results: The ideal image dimensions are: 800px width, 600px height. If an uploaded image exceeds either of these dimensions, it will need be resized to meet the requirements. Otherwise, leave as it is. The ideal file size is 200kb. If an uploaded image exceeds this then it will need to be compressed to meet this requirement. Otherwise, leave as it is. So in a nutshell: 1) Check the dimensions, resize if required. 2) Check the filesize, compress if required. Has anybody done anything like this / could you give me some pointers? Is PHPThumb the correct tool to do this in?

    Read the article

  • Resizing QT's QTextEdit to Match Text Height: maximumViewportSize()

    - by Aaron
    I am trying to use a QTextEdit widget inside of a form containing several QT widgets. The form itself sits inside a QScrollArea that is the central widget for a window. My intent is that any necessary scrolling will take place in the main QScrollArea (rather than inside any widgets), and any widgets inside will automatically resize their height to hold their contents. I have tried to implement the automatic resizing of height with a QTextEdit, but have run into an odd issue. I created a sub-class of QTextEdit and reimplemented sizeHint() like this: QSize OperationEditor::sizeHint() const { QSize sizehint = QTextBrowser::sizeHint(); sizehint.setHeight(this->fitted_height); return sizehint; } this-fitted_height is kept up-to-date via this slot that is wired to the QTextEdit's "contentsChanged()" signal: void OperationEditor::fitHeightToDocument() { this->document()->setTextWidth(this->viewport()->width()); QSize document_size(this->document()->size().toSize()); this->fitted_height = document_size.height(); this->updateGeometry(); } The size policy of the QTextEdit sub-class is: this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); I took this approach after reading this post. Here is my problem: As the QTextEdit gradually resizes to fill the window, it stops getting larger and starts scrolling within the QTextEdit, no matter what height is returned from sizeHint(). If I initially have sizeHint() return some large constant number, then the QTextEdit is very big and is contained nicely within the outer QScrollArea, as one would expect. However, if sizeHint gradually adjusts the size of the QTextEdit rather than just making it really big to start, then it tops out when it fills the current window and starts scrolling instead of growing. I have traced this problem to be that, no matter what my sizeHint() returns, it will never resize the QTextEdit larger than the value returned from maximumViewportSize(), which is inherited from QAbstractScrollArea. Note that this is not the same number as viewport()-maximumSize(). I am unable to figure out how to set that value. Looking at QT's source code, maximumViewportSize() is returning "the size of the viewport as if the scroll bars had no valid scrolling range." This value is basically computed as the current size of the widget minus (2 * frameWidth + margins) plus any scrollbar widths/heights. This does not make a lot of sense to me, and it's not clear to me why that number would be used anywhere in a way that supercede's the sub-class's sizeHint() implementation. Also, it does seem odd that the single "frameWidth" integer is used in computing both the width and the height. Can anyone please shed some light on this? I suspect that my poor understanding of QT's layout engine is to blame here.

    Read the article

  • Resizing an image using mouse dragging (C#)

    - by Gaax
    Hi all. I'm having some trouble resizing an image just by dragging the mouse. I found an average resize method and now am trying to modify it to use the mouse instead of given values. The way I'm doing it makes sense to me but maybe you guys can give me some better ideas. I'm basically using the distance between the current location of the mouse and the previous location of the mouse as the scaling factor. If the distance between the current mouse location and the center of of the image is less than the distance between previous mouse location and the center of the image then the image gets smaller, and vice-versa. With the code below I'm getting an Argument Exception (invalid parameter) when creating the new bitmap with the new height and width and I really don't understand why... any ideas? private static Image resizeImage(Image imgToResize, System.Drawing.Point prevMouseLoc, System.Drawing.Point currentMouseLoc) { int sourceWidth = imgToResize.Width; int sourceHeight = imgToResize.Height; float dCurrCent = 0; //Distance between current mouse location and the center of the image float dPrevCent = 0; //Distance between previous mouse location and the center of the image float dCurrPrev = 0; //Distance between current mouse location and the previous mouse location int sign = 1; System.Drawing.Point imgCenter = new System.Drawing.Point(); float nPercent = 0; imgCenter.X = imgToResize.Width / 2; imgCenter.Y = imgToResize.Height / 2; // Calculating the distance between the current mouse location and the center of the image dCurrCent = (float)Math.Sqrt(Math.Pow(currentMouseLoc.X - imgCenter.X, 2) + Math.Pow(currentMouseLoc.Y - imgCenter.Y, 2)); // Calculating the distance between the previous mouse location and the center of the image dPrevCent = (float)Math.Sqrt(Math.Pow(prevMouseLoc.XimgCenter.X,2) + Math.Pow(prevMouseLoc.Y - imgCenter.Y, 2)); // Calculating the sign value if (dCurrCent >= dPrevCent) { sign = 1; } else { sign = -1; } nPercent = sign * (float)Math.Sqrt(Math.Pow(currentMouseLoc.X - prevMouseLoc.X, 2) + Math.Pow(currentMouseLoc.Y - prevMouseLoc.Y, 2)); int destWidth = (int)(sourceWidth * nPercent); int destHeight = (int)(sourceHeight * nPercent); Bitmap b = new Bitmap(destWidth, destHeight); // exception thrown here Graphics g = Graphics.FromImage((Image)b); g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage(imgToResize, 0, 0, destWidth, destHeight); g.Dispose(); return (Image)b; }

    Read the article

  • jQuery dialog width resizing problem

    - by ktMen
    I try to load some HTML code into a jQueryUI dialog by AJAX. The code itself is a list, where rightmost elements should be absolutely positioned so that the list looks like a table with two columns, but only in some rows. The problem is that jQueryUI plugin does not seem to be correctly resizing the dialog's width, which I think is due to the absolute positioning of some li's. I have read some answers to other similar questions, but none helped me out with this. This is the code I load: <style type="text/css"> ul {list-style-type:none;margin:0px;padding:0px;} ul ul {margin:0px;padding:0px;} ul>li.fila {margin-bottom:5px;padding-bottom:5px;} ul li.fila ul li { display:inline; padding-left:20px; position:relative; margin-bottom:10px; } ul li.fila ul li.O { background:url(bullet.gif) 5px 8px no-repeat; list-style-position:inside; } </style> <ul id="raiz" > <li class="fila"> <ul > <li style="position:absolute;left:0px;" class="O"> <label for="col1">Col1:</label> <input type="text" name="col1" id="col1" value="vCol1" class="text ui-widget-content ui-corner-all" /> </li> <li style="left:250px;" class="O" > <label for="col2">Col2:</label> <input type="text" name="col2" id="col2" value="vCol2" class="text ui-widget-content ui-corner-all" /> </li> </ul> </li> <li class="fila"> <ul > <li> <label for="col3">Col3:</label> <input type="text" name="col3" id="col3" value="vCol3" class="text ui-widget-content ui-corner-all" /> </li> </ul> </li> </ul> And the Dialog constructor: $("#dialog").dialog({ bgiframe: true, autoOpen: false, height: 'auto', width: 'auto', modal: true, buttons:{ 'Cancel': function() { $(this).dialog('close'); } }, open: function(event,ui){ $("#dialog").load("dialogCode.html"); } }); Thanks in advance for any suggestions.

    Read the article

  • jQuery: resizing element cuts off parent's background

    - by Justine
    Hi, I've been trying to recreate an effect from this tutorial: http://jqueryfordesigners.com/jquery-look-tim-van-damme/ Unfortunately, I want a background image underneath and because of the resize going on in JavaScript, it gets resized and cut off as well, like so: http://dev.gentlecode.net/dotme/index-sample.html - you can view source there to check the HTML, but basic structure looks like this: <div class="page"> <div class="container"> div.header ul.nav div.main </div> </div> Here is my jQuery code: $('ul.nav').each(function() { var $links = $(this).find('a'), panelIds = $links.map(function() { return this.hash; }).get().join(","), $panels = $(panelIds), $panelWrapper = $panels.filter(':first').parent(), delay = 500; $panels.hide(); $links.click(function() { var $link = $(this), link = (this); if ($link.is('.current')) { return; } $links.removeClass('current'); $link.addClass('current'); $panels.animate({ opacity : 0 }, delay); $panelWrapper.animate({ height: 0 }, delay, function() { var height = $panels.hide().filter(link.hash).show().css('opacity', 1).outerHeight(); $panelWrapper.animate({ height: height }, delay); }); }); var showtab = window.location.hash ? '[hash=' + window.location.hash + ']' : ':first'; $links.filter(showtab).click(); }); In this example, panelWrapper is a div.main and it gets resized to fit the content of tabs. The background is applied to the div.page but because its child is getting resized, it resizes as well, cutting off the background image. It's hard to explain so please look at the link above to see what I mean. I guess what I'm trying to ask is: is there a way to resize an element without resizing its parent? I tried setting height and min-height of .page to 100% and 101% but that didn't work. I tried making the background image fixed, but nada. It also happens if I add the background to the body or even html. Help?

    Read the article

  • How to resize a Flot graph when its containing div changes size

    - by Will Gorman
    I'm using the Flot graphing library jQuery plugin and I haven't found a good way to handle resizing the graph when it's containing <div> changes size (for example, due to window resizing). When handling the onresize event, I've made sure that the width and height of the containing <div>are updated to the correct size and then tried calling both setupGrid and draw on the plot object but with no effect. I've had some success with the approach of just removing and readding the containing <div> and replotting the graph in it. However, this seems to be prone to getting stuck in infinite resize event loops if I have to add other <div> elements to the document at the same time (like for tooltips for the graph) as I'm guessing those can trigger resize events as well? Is there a good way to handle it that I'm missing? (I'm also using ExplorerCanvas for IE in order to be able to use Flot, if that might have anything to do with it. I haven't really tried in any other browsers yet)

    Read the article

  • Java - Problem when Resizing a JInternalFrame

    - by Amokrane
    Hi, In a previous SO question, I was talking about somes issues dealing with my MDI architecture. I have now another problem, when resizing my JInternalFrame. Here is a short video that illustrates the problem. I have a class: Cadre which is basically my JInternalFrame. public class Cadre extends JInternalFrame { /** Largeur par d'une fenêtre interne */ private int width; /** Hauteur d'une fenêtre interne */ private int height; /** Titre d'une fenêtre interne */ private String title; /** Toile associée à la fenêtre interne */ private Toile toile; /** Permet de compter le nombre de fenêtres internes ouvertes */ static int frameCount = 0; /** Permet de décaler les fenêtres internes à l'ouverture */ static final int xDecalage = 30, yDecalage = 30; public Cadre() { super("Form # " + (++frameCount), true, //resizable true, //closable true, //maximizable true);//iconifiable // Taille de la fenêtre interne par défaut width = 500; height = 500; // Titre par défaut title = "Form # " + (frameCount); // On associe une nouvelle toile à la fenêtre toile = new Toile(); this.setContentPane(toile); // On spécifie le titre this.setTitle(title); // Taille de chaque form par défaut this.setSize(width, height); // Permet d'ouvrir les frames de manière décalée par rapport à la dernière ouverte this.setLocation(xDecalage * frameCount, yDecalage * frameCount); } } And this is the JFrame that contains all the JInternalFrame(s): public class Fenetre extends JFrame { /** Titre de la fenêtre principale */ private String title; /** Largeur de la fenêtre */ private int width; /** Hauteur de la fenêtre */ private int height; /** Le menu */ private Menu menu; /** La barre d'outils */ private ToolBox toolBox; /** La zone contenant les JInternalFrame */ private JDesktopPane planche; /** Le pannel comportant la liste des formes à dessiner*/ private Pannel pannel; /** La liste de fenêtres ouvertes */ private static ArrayList<Cadre> cadres; public Fenetre(String inTitle, int inWidth, int inHeight) { // lecture de la taille de la frame width = inWidth; height = inHeight; // lecture du titre de la fenêtre title = inTitle; // On spécifie la taille de la fenêtre ainsi que le titre this.setSize(width, height); this.setTitle(title); // Initialisations des listes de cadres cadres = new ArrayList<Cadre>(); // Instanciation de la fenêtre this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // On définit un layout pour notre frame this.setLayout(new BorderLayout()); // On crée la zone supérieure : Menu + ToolBar JPanel banniere = new JPanel(); banniere.setLayout(new BorderLayout()); // Instanciation d'un menu menu = new Menu(this); this.setJMenuBar(menu); // En haut la ToolBox toolBox = new ToolBox(); this.add(toolBox, BorderLayout.NORTH); // Ajout du pannel à gauche pannel = new Pannel(); this.add(pannel, BorderLayout.WEST); **// Intialisation de la planche de dessin planche = new JDesktopPane(); // On ajoute une Internal frame à notre desktop pane Cadre cadre = new Cadre(); cadre.setVisible(true); planche.add(cadre); try { cadre.setSelected(true); } catch (PropertyVetoException e) { e.printStackTrace(); }** // Pour faire en sorte que le déplacement soit "nice" planche.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); // On ajoute le nouveau cadre crée à la liste des cadres cadres.add(cadre); // Le contenu principal de la fenêtre est la planche contenant les différentes JInternalFrame this.getContentPane().add(planche); this.setVisible(true); } } So as you can see, I have declared a: JDesktopPane inside the main JFrame of my application. Any idea how to solve this? Thank you!

    Read the article

  • Image Resizing: Poor jpeg quality and black PNG backgrounds

    - by azz0r
    Hello, I have two issues with my class, basically the quality of the jpeg images is quite poor, but I'm not sure if thats down to my ratio resizing. Ideally I'd like this class to be strict with image sizes and crop into them, but I cant get my head around it. My main issue is that pngs always have a black bg, does anyone have experience with this happening? <?php class OpenSource_ImageResize { function __construct($theFile, $toWhere, $mime, $extension, $newWidth, $newHeight) { if ($mime == NULL) { $mime = getimagesize($theFile); $mime = $mime['mime']; } if ($mime == 'image/jpeg') { $size = getimagesize($theFile); if ($size[0] > $newWidth || $size[1] > $newHeight) { $sourceImage = imagecreatefromjpeg($theFile); } else { return copy($theFile, $toWhere); throw new exception('Could not create jpeg'); return false; } } else if ($mime == 'image/png') { $size = getimagesize($theFile); if ($size[0] > $newWidth || $size[1] > $newHeight) { $sourceImage = imagecreatefrompng($theFile); } else { return copy($theFile, $toWhere); //throw new exception('Could not create png'); return false; } } else if ($mime == 'image/gif') { $size = getimagesize($theFile); if ($size[0] > $newWidth || $size[1] > $newHeight) { $sourceImage = imagecreatefromgif ($theFile); } else { return copy($theFile, $toWhere); //throw new exception('Could not create gif'); return false; } } else { throw new exception('Not a valid mime type'); return false; } $oldX = imageSX($sourceImage); $oldY = imageSY($sourceImage); if ($newWidth == NULL) { $thumbHeight = $newHeight; $thumbWidth = round($newHeight/($oldY/$oldX)); } else if ($oldX > $oldY) { $thumbWidth = $newWidth; $thumbHeight = $oldY * ($newHeight/$oldX); } if ($oldX < $oldY) { $thumbWidth = round($newHeight/($oldY/$oldX)); $thumbHeight = $newHeight; } if ($oldX == $oldY) { $thumbWidth = $newWidth; $thumbHeight = $newHeight; } if (!gd_info()) { $dstImage = ImageCreate($thumbWidth, $thumbHeight); imagecopyresized($dstImage, $sourceImage, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $oldX, $oldY); } else { $dstImage = ImageCreateTrueColor($thumbWidth, $thumbHeight); imagecopyresampled($dstImage, $sourceImage, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $oldX, $oldY); } if ($mime == 'image/png') { $xparent = imagecolorresolvealpha($dstImage, 255,2,240, 0) ; imagecolortransparent($dstImage,$xparent); imagealphablending($dstImage,true); imagepng($dstImage, $toWhere); } else if ($mime == 'image/jpeg') { imagejpeg($dstImage, $toWhere); } else if ($mime == 'image/gif') { imagegif ($dstImage, $toWhere); } imagedestroy($dstImage); imagedestroy($sourceImage); return true; } }

    Read the article

  • Issue with WIC image resizing on ASP.NET MVC 2

    - by Dave
    I am attempting to implement image resizing on user uploads in ASP.NET MVC 2 using a version of the method found: here on asp.net. This works great on my dev machine, but as soon as I put it on my production machine, I start getting the error 'Exception from HRESULT: 0x88982F60' which is supposed to mean that there is an issue decoding the image. However, when I use WICExplorer to open the image, it looks ok. I've also tried this with dozens of images of various sources and still get the error (though possible, I doubt all of them are corrupted). Here is the relevant code (with my debugging statements in there): MVC Controller [Authorize, HttpPost] public ActionResult Upload(string file) { //Check file extension string fx = file.Substring(file.LastIndexOf('.')).ToLowerInvariant(); string key; if (ConfigurationManager.AppSettings["ImageExtensions"].Contains(fx)) { key = Guid.NewGuid().ToString() + fx; } else { return Json("extension not found"); } //Check file size if (Request.ContentLength <= Convert.ToInt32(ConfigurationManager.AppSettings["MinImageSize"]) || Request.ContentLength >= Convert.ToInt32(ConfigurationManager.AppSettings["MaxImageSize"])) { return Json("content length out of bounds: " + Request.ContentLength); } ImageResizerResult irr, irr2; //Check if this image is coming from FF, Chrome or Safari (XHR) HttpPostedFileBase hpf = null; if (Request.Files.Count <= 0) { //Scale and encode image and thumbnail irr = ImageResizer.CreateMaxSizeImage(Request.InputStream); irr2 = ImageResizer.CreateThumbnail(Request.InputStream); } //Or IE else { hpf = Request.Files[0] as HttpPostedFileBase; if (hpf.ContentLength == 0) return Json("hpf.length = 0"); //Scale and encode image and thumbnail irr = ImageResizer.CreateMaxSizeImage(hpf.InputStream); irr2 = ImageResizer.CreateThumbnail(hpf.InputStream); } //Check if image and thumbnail encoded and scaled correctly if (irr == null || irr.output == null || irr2 == null || irr2.output == null) { if (irr != null && irr.output != null) irr.output.Dispose(); if (irr2 != null && irr2.output != null) irr2.output.Dispose(); if(irr == null) return Json("irr null"); if (irr2 == null) return Json("irr2 null"); if (irr.output == null) return Json("irr.output null. irr.error = " + irr.error); if (irr2.output == null) return Json("irr2.output null. irr2.error = " + irr2.error); } if (irr.output.Length > Convert.ToInt32(ConfigurationManager.AppSettings["MaxImageSize"]) || irr2.output.Length > Convert.ToInt32(ConfigurationManager.AppSettings["MaxImageSize"])) { if(irr.output.Length > Convert.ToInt32(ConfigurationManager.AppSettings["MaxImageSize"])) return Json("irr.output.Length > maximage size. irr.output.Length = " + irr.output.Length + ", irr.error = " + irr.error); return Json("irr2.output.Length > maximage size. irr2.output.Length = " + irr2.output.Length + ", irr2.error = " + irr2.error); } //Store scaled and encoded image and thumbnail .... return Json("success"); } The code is always failing when checking if the output stream is null (i.e. irr.output == null is true). ImageResizerResult and ImageResizer public class ImageResizerResult : IDisposable { public MemoryIStream output; public int width; public int height; public string error; public void Dispose() { output.Dispose(); } } public static class ImageResizer { private static Object thislock = new Object(); public static ImageResizerResult CreateMaxSizeImage(Stream input) { uint maxSize = Convert.ToUInt32(ConfigurationManager.AppSettings["MaxImageDimension"]); try { lock (thislock) { // Read the source image var photo = ByteArrayFromStream(input); var factory = (IWICComponentFactory)new WICImagingFactory(); var inputStream = factory.CreateStream(); inputStream.InitializeFromMemory(photo, (uint)photo.Length); var decoder = factory.CreateDecoderFromStream(inputStream, null, WICDecodeOptions.WICDecodeMetadataCacheOnDemand); var frame = decoder.GetFrame(0); // Compute target size uint width, height, outWidth, outHeight; frame.GetSize(out width, out height); if (width > height) { //Check if width is greater than maxSize if (width > maxSize) { outWidth = maxSize; outHeight = height * maxSize / width; } //Width is less than maxSize, so use existing dimensions else { outWidth = width; outHeight = height; } } else { //Check if height is greater than maxSize if (height > maxSize) { outWidth = width * maxSize / height; outHeight = maxSize; } //Height is less than maxSize, so use existing dimensions else { outWidth = width; outHeight = height; } } // Prepare output stream to cache file var outputStream = new MemoryIStream(); // Prepare JPG encoder var encoder = factory.CreateEncoder(Consts.GUID_ContainerFormatJpeg, null); encoder.Initialize(outputStream, WICBitmapEncoderCacheOption.WICBitmapEncoderNoCache); // Prepare output frame IWICBitmapFrameEncode outputFrame; var arg = new IPropertyBag2[1]; encoder.CreateNewFrame(out outputFrame, arg); var propBag = arg[0]; var propertyBagOption = new PROPBAG2[1]; propertyBagOption[0].pstrName = "ImageQuality"; propBag.Write(1, propertyBagOption, new object[] { 0.85F }); outputFrame.Initialize(propBag); outputFrame.SetResolution(96, 96); outputFrame.SetSize(outWidth, outHeight); // Prepare scaler var scaler = factory.CreateBitmapScaler(); scaler.Initialize(frame, outWidth, outHeight, WICBitmapInterpolationMode.WICBitmapInterpolationModeFant); // Write the scaled source to the output frame outputFrame.WriteSource(scaler, new WICRect { X = 0, Y = 0, Width = (int)outWidth, Height = (int)outHeight }); outputFrame.Commit(); encoder.Commit(); return new ImageResizerResult { output = outputStream, height = (int)outHeight, width = (int)outWidth }; } } catch (Exception e) { return new ImageResizerResult { error = "Create maxsizeimage = " + e.Message }; } } } Thoughts on where this is going wrong? Thanks in advance for the effort.

    Read the article

  • Need AngularJS grid resizing directive to resize "thumbnail" that contains no image

    - by thebravedave
    UPDATE Plunker to project: http://plnkr.co/edit/oKB96szQhqwpKQbOGUDw?p=preview I have an AngularJS project that uses AngularJS Bootstrap grids. I need all of the grid elements to have the same size so they stack properly. I created an angularJs directive that auto resizes the grid element when placed in said grid element. I have 2 directives that do this for me Directive 1: onload Directive 2: imageonload Directive 2 works. If the grid element uses an image, after the image loads then the directive triggers an event that sends the grid elements height to all other grid elements. If that height sent out via the event is greater than that of the grid element which is listening to the event then that listening grid element changes it's height to be the greater height. This way the largest height becomes the height for all the grid elements. Directive 1 does not work. This one is placed on the outer most grid elements html element, and is triggered when the element loads. The problem is that when the element loads and the onload directive is called AngularJS has not yet filled out the data in said grid element. The outcome is that the real height after AngularJS data binds is not broadcast as an event. My only solution I have thought of (but haven't tried) is to add an image url to an image that exists but doesn't have any data in it, and place that in the grid element (the one that didn't have any images before placing the blank one in). I could then call imageonload instead of onload and I pretty sure the angularjs data binding will have taken place by then. the problem is that that is pretty hacky. I would rather be able to have not an image in the grid element, and be able to call my custom onload directive and have the onload directive calculate the height AFTER angularJS data binds to all of the data binding variables in the grid element. Here is my imageonload directive .directive('imageonload', function($rootScope) { return { restrict: 'A', link: function(scope, element, attrs) { scope.heightArray = []; scope.largestHeight = 50; element.bind('load', function() { broadcastThumbnailHeight(); }); scope.$on('imageOnLoadEvent', function(caller, value){ var el = angular.element(element); var id = el.prop('id'); var pageName = el.prop('title'); if(pageName == value[0]){ if(scope.largestHeight < value[1]){ scope.largestHeight = value[1]; var nestedString = el.prop('alt'); if(nestedString == "") nestedString = "1"; var nested = parseInt(nestedString); nested = nested - 1; var inte = 0; var thumbnail = el["0"]; var finalThumbnailContainer = thumbnail.parentElement; while(inte != nested){ finalThumbnailContainer = finalThumbnailContainer.parentElement; inte++; } var innerEl = angular.element(finalThumbnailContainer); var height = value[1]; innerEl.height(height); } } }); scope.$on('findHeightAndBroadcast', function(){ broadcastThumbnailHeight(); }); scope.$on('resetThumbnailHeight', function(){ scope.largestHeight = 50; }); function broadcastThumbnailHeight(){ var el = angular.element(element); var id = el.prop('id'); var alt = el.prop('alt'); if(alt == "") alt = "1"; var nested = parseInt(alt); nested = nested - 1; var pageName = el.prop('title'); var inte = 1; var thumbnail = el["0"]; var finalThumbnail = thumbnail.parentElement; while(inte != nested){ finalThumbnail = finalThumbnail.parentElement; inte++; } var elZero = el["0"]; var clientHeight = finalThumbnail.clientHeight; var arr = []; arr[0] = pageName; arr[1] = clientHeight; $rootScope.$broadcast('imageOnLoadEvent', arr); } } }; }) And here is my onload directive .directive('onload', function($rootScope) { return { restrict: 'A', link: function(scope, element, attrs) { scope.largestHeight=100; getHeightAndBroadcast(); scope.$on('onLoadEvent', function(caller, value){ var el = angular.element(element); var id = el.prop('id'); var pageName = el.prop('title'); if(pageName == value[0]){ if(scope.largestHeight < value[1]){ scope.largestHeight = value[1]; var height = value[1]; el.height(height); } } }); function getHeightAndBroadcast(){ var el = angular.element(element); var h = el["0"].children; var thumbnailHeightElement = angular.element(h); var pageName = el.prop("title"); var clientHeight = thumbnailHeightElement["0"].clientHeight; var arr = []; arr[0] = pageName; arr[1] = clientHeight; if(clientHeight != undefined) $rootScope.$broadcast('onLoadEvent', arr); } } }; }) Here is an example of one of my grid elements that uses imageonload. Note the imageonload directive in the image html element. This works. There is also an onload directive on the outer most html of the grid element. That does not work. I have stepped through this carefully in Firebug and saw that the onload was calculating the height before AngularJS data binding was complete. <div class="thumbnail col-md-3" id="{{product.id}}" title="thumbnailAdminProductsGrid" onload> <div class="row"> <div class="containerz"> <div class="row-fluid"> <div class="col-md-2"></div> <div class="col-md-7"> <div class="textcenterinline"> <!--tag--><img class="img-responsive" id="{{product.id}}" title="imageAdminProductsGrid" alt=6 ng-src="{{product.baseImage}}" imageonload/><!--end tag--> </div> </div> </div> <div class="caption"> <div class="testing"> <div class="row-fluid"> <div class="col-md-12"> <h3 class=""> <!--tag--><a href="javascript:void(0);" ng-click="loadProductView('{{product.id}}')">{{product.name}}</a><!--end tag--> </h3> </div> </div> <div class="row-fluid"> <div class="col-md-12"> <p class="lead"><!--tag--> {{product.price}}</p><!--end tag--> </div> </div> <div class="row-fluid"> <div class="col-md-12"> <p><!--tag-->{{product.inStock}} units available<!--end tag--></p> </div> </div> <div class="row-fluid"> <div class="col-md-12"> <p class=""><!--tag-->{{product.generalDescription}}<!--end tag--></p> </div> </div> <!--tag--> <div data-ng-if="product.specialized=='true'"> <div class="row-fluid"> <div class="col-md-12" ng-repeat="varCat in product.varietyCategoriesAndOptions"> <b><h4>{{varCat.varietyCategoryName}}</h4></b> <select ng-model="varCat.varietyCategoryOption" ng-options="value.varietyCategoryOptionId as value.varietyCategoryOptionValue for (key,value) in varCat.varietyCategoryOptions"> </select> </div> </div> </div> <!--end tag--> <div class="row-fluid"> <div class="col-md-12"> <!--tag--><div ng-if="product.weight==0"><b>Free Shipping</b></div><!--end tag--> </div> </div> </div> </div> </div> </div> Here is an example of one of the html for one of my grid elements that only uses the "onload" directive and not "imageonload" <div class="thumbnail col-md-3" title="thumbnailCouponGrid" onload> <div class="innnerContainer"> <div class="text-center"> {{coupon.name}} <br /> <br /> <b>Description</b> <br /> {{coupon.description}} <br /> <br /> <button class="btn btn-large btn-primary" ng-click="goToCoupon()">View Coupon Details</button> </div> </div> The imageonload function might look a little confusing because I use the img html attribute "alt" to signal to the directive how many levels the imageonload is placed below the outermost html for the grid element. We have to have this so the directive knows which html element to set the new height on. also I use the "title" attribute to set which grid this grid resizing is for (that way you can use the directive multiple times on the same page for different grids and not have the events for the wrong grid triggered). Does anyone know how I can get the "onload" directive to get called AFTER angularJS binds to the grid element? Just for completeness here are 2 images (almost looks like just 1), the second is a grid that contains grid elements that have images and use the "imageonload" directive and the first is a grid that contains grid elements that do not use images and only uses the "onload" directive.

    Read the article

  • Scaling VideoView on Android

    - by Mumbles
    I am creating a video player on android and am having trouble resizing the video. I am trying to make it so that when i click the video it goes to full screen covering everything and if i click again it goes back to the smaller size with other buttons on the screen. I have seen another similar problem and an answer from haseman (http://stackoverflow.com/questions/2068242/does-android-support-scaling-video) and I think this would work but am not sure how to achieve this, Any help would be much appreciated

    Read the article

  • What is the fastest way to resize a large partition?

    - by Jook
    Due to a new HDD-Configuration I am currently handling larger backup/resize tasks with partitions between around 900MB, wich are 70-90% full. some background: First thing I've noticed was, that the Acronis-WesternDigital TrueImage was extremly slow while running it under Windows 7, even though on high priority. To create a normal backup for 650gb of data (900gb partition), it would have taken 3 days! The same task done with the boot-cd version of this acronis version took about 2 hours (SATA3 copy from one disk to another, both around 110MB/s). Now, after I have done all my backups, I've wanted to remove some obsolete partitions and resize the leftovers to full hdd size. Of course, usually this takes quite some time - in this case for this 900gb partition, to extend it to 931 (30gb+ from front, 1gb+ from end), it will take around 6 hours (using gparted)! Had I new that erlier, I would have just restored the image. But no - first it showed a reasonable time of 1:45h and 0 of 1 operations, but after finishing 1:45h it started again, only this time with 4h to go, still 0 of 1 operations, but now it was copying instead of moving. Question: However, why has it to be this slow to resize a partition? I am asking for a good explanaition. This has bugged me, since I started partitioning - why does it require to copy all the data around, can't it just stay in place?!

    Read the article

  • How to prevent windows from being resized?

    - by endolith
    Adobe Audition is really stupid in that when you change the size of the window, and then change it back to the original size, all the frame positions are lost and you have to tediously reposition them by hand. I'd like to make it completely impossible to ever resize the window, just keep it maximized at all times. If I accidentally click "Restore" or drag the title bar, it should either ignore it, or move around the screen while staying the same size. Is there any way to do this?

    Read the article

  • Resizing an image with stretchableImageWithLeftCapWidth

    - by Stephan Burlot
    I'm trying to resize an image using stretchableImageWithLeftCapWidth: it works on the simulator, but on the device, vertical green bars appears. I've tried to use imageNamed, imageWithContentOfFile and imageWithData lo load the image, it doesnt change. UIImage *bottomImage = [[UIImage imageWithData: [NSData dataWithContentsOfFile: [NSString stringWithFormat:@"%@/bottom_part.png", [[NSBundle mainBundle] resourcePath]]]] stretchableImageWithLeftCapWidth:27 topCapHeight:9]; UIImageView *bottomView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 200+73, 100, 73)]; [self.view addSubview:bottomView]; UIGraphicsBeginImageContext(CGSizeMake(100, 73)); [bottomImage drawInRect:CGRectMake(0, 0, 100, 73)]; UIImage *bottomResizedImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); bottomView.image = bottomResizedImage; See the result: the green bars shouldn't be there, they dont appear on the simulator.

    Read the article

  • Jquery cycle plugin image resizing issue opera

    - by Sam Gregory
    I am using the cycle plugin within Joomla and it works fine on IE6,FF,SAFARI,CHROME however when you view it in OPERA breaking happens. It loads fine but when it brings in the next slide and every consequent slide after that it re-sizes them to what i can only assume to be the browswe window's width and height. here's my javascript <script type="text/javascript"> $('.fullScreen').cycle({ speed: 1000, timeout: 100 }); </script> css <script type="text/css"> .fullScreen { margin-left: 0px; height: 355px; clear: both; width: 475px; z-index: -1; overflow: hidden; } </script> and finally HTML <div class="fullscreen"> <img width="475px" src="images/someimage1.jpg" /> <img width="475px" src="images/someimage2.jpg" /> <img width="475px" src="images/someimage3.jpg" /> </div> hope I'm not the only one having this problem.

    Read the article

  • C# resize all elements in form when resizing form

    - by vale4674
    NOTE: I can't put more than one hyperlink so i deleted letter "h" on begining of every link I have this image as the background of the form: ttp://img811.imageshack.us/img811/3347/31886905.jpg So my form looks like this: ttp://img823.imageshack.us/i/cisto.jpg/ When i resize it it looks like this: ttp://img820.imageshack.us/i/cistoumanjeno.jpg/ Now what I need to do is to put listeners on every rextangle like on the picture: ttp://img810.imageshack.us/img810/238/18887457.jpg I made transparent panels and put them on form to match the rectangles on the image (on image, panels are green so you can see where they are): ttp://img809.imageshack.us/i/paneli.jpg/ but when I resize the form it turns like this: ttp://img810.imageshack.us/i/paneliumanjeno.jpg/ anchor and dock properties don't work because they rely on parent container and here rectangles are on background image. QUESTION: I would like to do something like "relative-resize and position". Is that posible? So when I resize form, all the panels fits the rectangles on image.

    Read the article

  • PHP/GD - Cropping and Resizing Images

    - by Alix Axel
    I've coded a function that crops an image to a given aspect ratio and finally then resizes it and outputs it as JPG: <?php function Image($image, $crop = null, $size = null) { $image = ImageCreateFromString(file_get_contents($image)); if (is_resource($image) === true) { $x = 0; $y = 0; $width = imagesx($image); $height = imagesy($image); /* CROP (Aspect Ratio) Section */ if (is_null($crop) === true) { $crop = array($width, $height); } else { $crop = array_filter(explode(':', $crop)); if (empty($crop) === true) { $crop = array($width, $height); } else { if ((empty($crop[0]) === true) || (is_numeric($crop[0]) === false)) { $crop[0] = $crop[1]; } else if ((empty($crop[1]) === true) || (is_numeric($crop[1]) === false)) { $crop[1] = $crop[0]; } } $ratio = array ( 0 => $width / $height, 1 => $crop[0] / $crop[1], ); if ($ratio[0] > $ratio[1]) { $width = $height * $ratio[1]; $x = (imagesx($image) - $width) / 2; } else if ($ratio[0] < $ratio[1]) { $height = $width / $ratio[1]; $y = (imagesy($image) - $height) / 2; } /* How can I skip (join) this operation with the one in the Resize Section? */ $result = ImageCreateTrueColor($width, $height); if (is_resource($result) === true) { ImageSaveAlpha($result, true); ImageAlphaBlending($result, false); ImageFill($result, 0, 0, ImageColorAllocateAlpha($result, 255, 255, 255, 127)); ImageCopyResampled($result, $image, 0, 0, $x, $y, $width, $height, $width, $height); $image = $result; } } /* Resize Section */ if (is_null($size) === true) { $size = array(imagesx($image), imagesy($image)); } else { $size = array_filter(explode('x', $size)); if (empty($size) === true) { $size = array(imagesx($image), imagesy($image)); } else { if ((empty($size[0]) === true) || (is_numeric($size[0]) === false)) { $size[0] = round($size[1] * imagesx($image) / imagesy($image)); } else if ((empty($size[1]) === true) || (is_numeric($size[1]) === false)) { $size[1] = round($size[0] * imagesy($image) / imagesx($image)); } } } $result = ImageCreateTrueColor($size[0], $size[1]); if (is_resource($result) === true) { ImageSaveAlpha($result, true); ImageAlphaBlending($result, true); ImageFill($result, 0, 0, ImageColorAllocate($result, 255, 255, 255)); ImageCopyResampled($result, $image, 0, 0, 0, 0, $size[0], $size[1], imagesx($image), imagesy($image)); header('Content-Type: image/jpeg'); ImageInterlace($result, true); ImageJPEG($result, null, 90); } } return false; } ?> The function works as expected but I'm creating a non-required GD image resource, how can I fix it? I've tried joining both calls but I must be doing some miscalculations. <?php /* Usage Examples */ Image('http://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png', '1:1', '600x'); Image('http://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png', '2:1', '600x'); Image('http://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png', '2:', '250x300'); ?> Any help is greatly appreciated, thanks.

    Read the article

  • WPF Formatting Issues - Automatically stretching and resizing?

    - by Adam S
    I'm very new to WPF and XAML. I am trying to design a basic data entry form. I have used a stack panel holding four more stack panels to get the layout I want. Perhaps a grid would be better for this, I am not sure. Here is an image of my form in action: http://yfrog.com/7gscreenshot1impp And here is the XAML code that generates it: <Window x:Class="Test1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="224" Width="536.762"> <StackPanel Height="Auto" Name="stackPanel1" Width="Auto" Orientation="Horizontal"> <StackPanel Height="Auto" Name="stackPanel2" Width="Auto"> <Label Height="Auto" Name="label1" Width="Auto">Patient Name:</Label> <Label Height="Auto" Name="label2" Width="Auto">Physician:</Label> <Label Height="Auto" Name="label3" Width="Auto">Insurance:</Label> <Label Height="Auto" Name="label4" Width="Auto">Therapy Goals:</Label> </StackPanel> <StackPanel Height="Auto" Name="stackPanel3" Width="Auto"> <TextBox Height="Auto" Name="textBox1" Width="Auto" Padding="3" Margin="1" /> <TextBox Height="Auto" Name="textBox2" Width="Auto" Padding="3" Margin="1" /> <TextBox Height="Auto" Name="textBox3" Width="Auto" Padding="3" Margin="1" /> <TextBox Height="Auto" Name="textBox4" Width="Auto" Padding="3" Margin="1" /> </StackPanel> <StackPanel Height="Auto" Name="stackPanel4" Width="Auto"> <Label Height="Auto" Name="label5" Width="Auto">Date:</Label> <Label Height="Auto" Name="label6" Width="Auto">Patient Phone:</Label> <Label Height="Auto" Name="label7" Width="Auto">Facility:</Label> <Label Height="Auto" Name="label8" Width="Auto">Referring Physician:</Label> </StackPanel> <StackPanel Height="Auto" Name="stackPanel5" Width="Auto"> <TextBox Height="Auto" Name="textBox5" Width="Auto" Padding="3" Margin="1" /> <TextBox Height="Auto" Name="textBox6" Width="Auto" Padding="3" Margin="1" /> <TextBox Height="Auto" Name="textBox7" Width="Auto" Padding="3" Margin="1" /> <TextBox Height="Auto" Name="textBox8" Width="Auto" Padding="3" Margin="1" /> </StackPanel> </StackPanel> </Window> What I really want is for the text boxes to stretch equally to fill up the space horizontally. I would also like for the controls in each vertical stackpanel to 'spread out' evenly as the window is resized vertically. Can any of you experts out there help me out?

    Read the article

  • LibraryContainer in a ScatterViewItem: resizing and background rectangle...

    - by Rob Fleming
    Simple one: Want to add a LibraryContainer to a Surface ScatterView. Know I have to add the container inside a ScatterViewItem to get the rotate/move features.. but the SVI adds a rectangle box around the control, and it does not size correctly. Think I'm missing something simple but can't figure it... My current XAML is as follows: Background="{StaticResource WindowBackground}" AllowDrop="True" . . . Any thoughts are appreciated... I've been looking at the how-to samples but the library controls that are shown are static item. (ie they are not movable)... Rob

    Read the article

  • Resizing and rotating an image in Android

    - by kingrichard2005
    I'm trying to rotate and resize an image in Android. The code I have is as follows, (taken from this tutorial): Bitmap originalSprite = BitmapFactory.decodeResource(getResources(), R.drawable.android); int orgHeight = a.getHeight(); int orgWidth = a.getWidth(); //Create manipulation matrix Matrix m = new Matrix(); // resize the bit map m.postScale(.25f, .25f); // rotate the Bitmap by the given angle m.postRotate(180); //Rotated bitmap Bitmap rotatedBitmap = Bitmap.createBitmap(originalSprite, 0, 0, orgWidth, orgHeight, m, true); return rotatedBitmap; The image seems to rotate just fine, but it doesn't scale like I expect it to. I've tried different values, but the image only gets more pixelized as I reduce the scale values, but remains that same size visually; whereas the goal I'm trying to achieve is to actually shrink it visually. I'm not sure what to do at this point, any help is appreciated.

    Read the article

  • Dynamically resizing CMFCPropertySheet with PropSheetLook_OneNoteTabs style

    - by Ryan
    Hi everybody, I'm trying to resize dynamically a CMFCPropertySheet to add a custom control at the bottom of each page. As all Property Pages are not of the same height, I have a mechanism to increase the size if necessary. For this, I have overridden the OnActivatePage method and by using SetWindowPos, I can resize the sheet, first, then the tab control, then the page and finally I can move the OK/Cancel/Help buttons. It works fine with PropSheetLook_OutlookBar and PropSheetLook_Tabs styles but not with PropSheetLook_OneNoteTabs style. The page (or the tab) is not correctly resized (the lighter grey color of the page does not fill the sheet. OneNote style Outlook style Any idea? A MFC Feature Pack bug?

    Read the article

  • Resizing JPEG image during decoding

    - by Thomas
    I'm working on a program that creates thumbnails of JPEG images on the fly. Now I was thinking: since a JPEG image is built from 8x8-pixel blocks (Wikipedia has a great explanation), would it be possible to skip part of the decoding? Let's say that my thumbnails are at least 8 times smaller than the original image. We could then map each 8x8 block in the input file to 1 pixel in the decoding output, by including only the constant term of the discrete cosine transform. Most of the image data can be discarded right away, and need not be processed. Moreover, the memory usage is reduced by a factor of 64. I don't want to implement this from scratch; that'll easily take a week. Is there any code out there that can do this? If not, is this because this approach isn't worthwhile, or simply because nobody has thought of it yet?

    Read the article

  • Resizing and saving an image in WinMobile and .NET CF throws OutOfMemoryException

    - by devguy
    I have a WinMobile app which allows the user the snap a photo with the camera, and then use for for various things. The photo can be snapped at 1600x1200, 800x600 or 640x480, but it must always be resized to 400px for the longest size (the other is proportional of course). Here's the code: private void LoadImage(string path) { Image tmpPhoto = new Bitmap(path); // calculate new bitmap size... double width = ... double height = ... // draw new bitmap Image photo = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); using (Graphics g = Graphics.FromImage(photo)) { g.FillRectangle(new SolidBrush(Color.White), new Rectangle(0, 0, photo.Width, photo.Height)); int srcX = (int)((double)(tmpPhoto.Width - width) / 2d); int srcY = (int)((double)(tmpPhoto.Height - height) / 2d); g.DrawImage(tmpPhoto, new Rectangle(0, 0, photo.Width, photo.Height), new Rectangle(srcX, srcY, photo.Width, photo.Height), GraphicsUnit.Pixel); } tmpPhoto.Dispose(); // save new image and dispose photo.Save(Path.Combine(config.TempPath, config.TempPhotoFileName), System.Drawing.Imaging.ImageFormat.Jpeg); photo.Dispose(); } Now the problem is that the app breaks in the photo.Save call, with an OutOfMemoryException. And I don't know why, since I dispose the tempPhoto (with the original photo from the camera) as soon as I can, and I also dispose the Graphics obj. Why does this happen? It seems impossible to me that one can't take a photo with the camera and resize/save it without making it crash :( Should I restor t C++ for such a simple thing? Thanks.

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >