Search Results

Search found 154 results on 7 pages for 'clipping'.

Page 2/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • Performance: float to int cast and clipping result to range

    - by durandai
    I'm doing some audio processing with float. The result needs to be converted back to PCM samples, and I noticed that the cast from float to int is surprisingly expensive. Whats furthermore frustrating that I need to clip the result to the range of a short (-32768 to 32767). While I would normally instictively assume that this could be assured by simply casting float to short, this fails miserably in Java, since on the bytecode level it results in F2I followed by I2S. So instead of a simple: int sample = (short) flotVal; I needed to resort to this ugly sequence: int sample = (int) floatVal; if (sample > 32767) { sample = 32767; } else if (sample < -32768) { sample = -32768; } Is there a faster way to do this? (about ~6% of the total runtime seems to be spent on casting, while 6% seem to be not that much at first glance, its astounding when I consider that the processing part involves a good chunk of matrix multiplications and IDCT) EDIT The cast/clipping code above is (not surprisingly) in the body of a loop that reads float values from a float[] and puts them into a byte[]. I have a test suite that measures total runtime on several test cases (processing about 200MB of raw audio data). The 6% were concluded from the runtime difference when the cast assignment "int sample = (int) floatVal" was replaced by assigning the loop index to sample. EDIT @leopoldkot: I'm aware of the truncation in Java, as stated in the original question (F2I, I2S bytecode sequence). I only tried the cast to short because I assumed that Java had an F2S bytecode, which it unfortunately does not (comming originally from an 68K assembly background, where a simple "fmove.w FP0, D0" would have done exactly what I wanted).

    Read the article

  • How does Silverlight Image Clipping work?

    - by TreeUK
    I've got a very large image which I'd like to use for sprite techniques (à la css image sprites). I've got the code below: <Image x:Name="testImage" Width="24" Height="12" Source="../Resources/Images/sprites.png"> <Image.Clip> <RectangleGeometry Rect="258,10632,24,12" /> </Image.Clip> </Image> This clips the source image to 24x12 at the relative position of 258, 10632 in the source image. The problem is that I want the cropped image to show at 0,0 in the testImage whereas it shows it at 258, 10632. It's using the geometry as a cutting guide but also as a layout guide. Anyone have any idea how this should be done? if at all. Conclusion: There seems to be no good way of doing this at present, Graeme's solution seems to be the closest to achieving this with Silverlight 2.0. That said, if anyone knows of a better way of doing this, please reply with an answer.

    Read the article

  • Android animation clipping when going between layouts

    - by Ravedave
    I have a fairly complex layout. I use a relative layout as the root and then inside of it I have a few table views and some further nesting. When I animate an imageview between these layouts my image clips. I have a background on the parent layout and the animation looks like it's going under it. I have set android:clipChildren="false" and android:clipToPadding="false" on all of the layouts. I've also set anim.setZAdjustment(Animation.ZORDER_TOP); on all of my animations. What am I doing wrong?

    Read the article

  • Clipping users cursor around the X button.

    - by Nowayz
    This should be simple, and I was hoping to do it in Delphi. The purpose of this is just supposed to be a joke. On a windows form application I don't want the user to be able to clip the X button on the main form. I want the cursor to either clip around the X button or just set it's position elsewhere.

    Read the article

  • Silverlight clipping a string on mac

    - by Haris
    hello, I am facing a very strange issue in my silverlight app on all browsers on mac but it is working perfectly in all windows browsers. in my silverlight app there is a scenario in which I create a very long text string and then pass it to a wcf service which then saves the string in a text file server. the issue is that in mac every time string is clipped after about same location. but it is working perfectly fine in all browsers on windows. btw in silverlight I am using string builder to build the string.

    Read the article

  • absolute positioned element clipping if position outside its parent item IE7

    - by yazz
    Hi Im trying to position an element so its slightly positioned outside its parent item. In IE8 it works but in IE7 the positioned element gets clipped. Here's my code HTML: <div id="parent"> <div id="child">text</div> </div> The CSS #parent { height: 40px; width: 400px; position: relative; } #child { position: absolute; width: 100px; height: 60px; top: 0px; left: 0px; } In IE7 you will see that the last 20px of the child element gets clipped. How can I solve this? THX

    Read the article

  • WFP Textblock in Listbox not clipping properly

    - by Tobias Funke
    Her's what I want: A listbox whose items consist of a stackpanel with two textblocks. The textblocks need to support wrapping, the listbox should not expand, and there should be no horizontal scrollbar. Here's the code I have so far. Copy and paste it into XamlPad and you'll see what I'm talking about. <ListBox Height="300" Width="300" x:Name="tvShows"> <ListBox.Items> <ListBoxItem> <StackPanel> <TextBlock Width="{Binding ElementName=tvShows, Path=ActualWidth}" TextWrapping="Wrap">Lost is an American live-action television series. It follows the lives of plane crash survivors on a mysterious tropical island.</TextBlock> <TextBlock Width="{Binding ElementName=tvShows, Path=ActualWidth}" TextWrapping="Wrap">Lost is an American live-action television series. It follows the lives of plane crash survivors on a mysterious tropical island.</TextBlock> </StackPanel> </ListBoxItem> <ListBoxItem> <StackPanel> <TextBlock Width="{Binding ElementName=tvShows, Path=ActualWidth}" TextWrapping="Wrap">Lost is an American live-action television series. It follows the lives of plane crash survivors on a mysterious tropical island.</TextBlock> <TextBlock Width="{Binding ElementName=tvShows, Path=ActualWidth}" TextWrapping="Wrap">Lost is an American live-action television series. It follows the lives of plane crash survivors on a mysterious tropical island.</TextBlock> </StackPanel> </ListBoxItem> </ListBox.Items> </ListBox> This seems to be doing the job of keeping the textblocks from growing, but there's one problem. The textblocks seem to be slightly larger than the listbox, causing the horizontal scrollbar to appear. This is strange because their widths are bound to the lisbox's ActualWidth. Also, if you add a few more items to the listbox (just cut and paste in XamlPad) causing the vertical scrollbar to appear, the width of the textblocks do not resize to the vertical scrollbar. How do I keep the textblocks inside the listbox, with or without the vertical scrollbar?

    Read the article

  • Library for polygon operations

    - by AJM
    I've recently encountered a need for a library or set of libraries to handle operations on 2D polygons. I need to be able to perform boolean/clipping operations (difference and union) and triangulation. So far the libraries I've found are poly2tri, CGAL, and GPC. Poly2tri looks good for triangulation but I'm still left with boolean operations, and I'm unsure about its maturity. CGAL and GPC are only free if my own project is free. My particular project isn't commercial, so I'm hesitant to pay or request for any licenses. But I may want to use my code for a future commercial project, so I'm hesitant about CGAL's open source licenses and GPC's freeware-only restriction. There doesn't seem to be any polygon clipping libraries with nice BSD-style licenses.

    Read the article

  • How to clip the contents of a custom NSView?

    - by Paperflyer
    I have a custom NSView that displays a nice scale/ruler. I am drawing text labels that are partly outside the actual drawing area so they get clipped by the view (looks nice). Now, I want to introduce empty side margins into the view and need to clip its content manually. How can I set up a custom clipping rectangle?

    Read the article

  • Why enabling transparency can lead to cliping problems ?

    - by Amokrane
    Hi, I'm working on a 3D graphical application in Java using the Java 3D API. I noticed that every time I was dealing with transparency, all I got in return were some clipping problems. Some parts of the scene weren't displayed properly. It might seem obvious that this would happen in a certain way but I'm looking for a logical explanation, why is this happening? Thank you

    Read the article

  • Building a clip area in a UIView from path objects in its subviews

    - by hkatz
    I'm trying to produce a clipping area in a UIView that's generated from path objects in its subviews. For example, I might have one subview containing a square and another containing a circle. I want to be able to produce a clip in the parent superview that's the union of both these shapes. Can someone explain how to do this? About all I've been able to figure out so far is that: 1 - the superview's drawRect: method is called before its subviews' drawRects are, and 2 - the ContextRef that's accessible in all three instances is the same. Other than that I'm stumped. Thanks, Howard

    Read the article

  • How can I create "glass" effect on my own UIViews?

    - by lindes
    Hi there, I'm working on an iPhone app that has some non-rectangular UI elements. Currently, I'm subclassing UIView, and in drawRect I'm using a CGPathRef to draw black border and a color-filled interior. I'd like to make these items look more like "buttons", though, so I'd like to have some of the same sort of "glass effects" that are used on e.g. the icons for an iPhone app (when you don't set UIPrerenderedIcon to true), or in other buttons. I hunted around, and found this, which seems to be close to what I need: http://stackoverflow.com/questions/422066/gradients-on-uiview-and-uilabels-on-iphone But I'm having difficulty figuring out how to clip the gradient to my shape. It seems like the mask property on the view would be the right place to go, which seems like it would call for me to create a new CALayer object, with the clipping somehow applied to it. I'm hoping there's some nice convenience function for doing this, though if I need to write something more complicated, that's OK, too. I'm just having difficulty figuring out how to apply the path as a mask. I'm unsure if I need to create a new drawing context and draw the path into it? And then use CGContextClip? I think I've got a lot of the right pieces figured out, I'm just having difficulty understanding how to assemble them. Could someone please point me in the right direction? (I'm happy to read more in the docs, just point me in the right direction, please.)

    Read the article

  • How to reset the context to the original rectangle after clipping it for drawing?

    - by mystify
    I try to draw a sequence of pattern images (different repeated patterns in one view). So what I did is this, in a loop: CGContextRef context = UIGraphicsGetCurrentContext(); // clip to the drawing rectangle to draw the pattern for this portion of the view CGContextClipToRect(context, drawingRect); // the first call here works fine... but for the next nothing will be drawn CGContextDrawTiledImage(context, CGRectMake(0, 0, 2, 31), [img CGImage]); I think that after I've clipped the context to draw the pattern in the specific rectangle, I cut out a snippet from the big canvas and the next time, my canvas is gone. can't cut out another snippet. So I must reset that clipping somehow in order to be able to draw another pattern again somewhere else? Edit: In the documentation I found this: CGContextClip: "... Therefore, to re-enlarge the paintable area by restoring the clipping path to a prior state, you must save the graphics state before you clip and restore the graphics state after you’ve completed any clipped drawing. ..." Well then, how to store the graphics state before clipping and how to restore it?

    Read the article

  • Algorithm for finding a rectangle constrained to its parent

    - by Milo
    Basically what I want to do is illustrated here: I start with A and B, then B is conformed to A to create C. The idea is, given TLBR rectangles A, B, make C I also need to know if it produces an empty rectangle (B outside of A case). I tried this but it just isn't doing what I want: if(clipRect.getLeft() > rect.getLeft()) L = clipRect.getLeft(); else L = rect.getLeft(); if(clipRect.getRight() < rect.getRight()) R = clipRect.getRight(); else R = rect.getRight(); if(clipRect.getBottom() > rect.getBottom()) B = clipRect.getBottom(); else B = rect.getBottom(); if(clipRect.getTop() < rect.getTop()) T = clipRect.getTop(); else T = rect.getTop(); if(L < R && B < T) { clipRect = AguiRectangle(0,0,0,0); } else { clipRect = AguiRectangle::fromTLBR(T,L,B,R); } Thanks

    Read the article

  • WPF: When is a WrapPanel full.

    - by rathkopf
    I'm using a WrapPanel to display variable height items in columns. The wrappanel has a constrained size. Is there an way to determine when the WrapPanel is 'full'? I will then page to another panel with an animation. I've looked at the ArrangeOverride of the items that are the panels children, but they always seem to be getting all the space they want. I need a way to determine when they begin getting clipped.

    Read the article

  • RectangleGeometry with relative dimensions... how?

    - by Padu Merloti
    I'm trying to replicate the nowadays so fashionable "reflex" effect on a controltemplate for buttons I'm creating. The basic idea is to create a rectangle with a gradient fill from white to transparent and then clip some of that semi-transparent rectangle with a rectanglegeometry. The problem is that I don't know how to define a relative rectangle geometry. I kind of worked around width by defining a large value (1000), but height is a problem. For example, it works good for buttons that have a 200 height, but doesn't do anything for smaller buttons. Any ideas? <Rectangle RadiusX="5" RadiusY="5" StrokeThickness="1" Stroke="Transparent"> <Rectangle.Fill> <LinearGradientBrush StartPoint="0,0" EndPoint="0,0.55"> <GradientStop Color="#66ffffff" Offset="0.0" /> <GradientStop Color="Transparent" Offset="1.0" /> </LinearGradientBrush> </Rectangle.Fill> <Rectangle.Clip> <RectangleGeometry Rect="0,0,1000,60" /> </Rectangle.Clip> </Rectangle>

    Read the article

  • Adding a subview larger than cellHeight to a UITableViewCell?

    - by MathieuK
    I'm trying to add a subview to a UITableViewCell and the design that I'm working from demands that this particular subview (an image) needs to be larger than the actual UITableViewCell and thus partly overlap its siblings. So I've set up my table cell, generated my image and added it to the cell's contentView: // rowHeight for the UITableView is 45.0f UIImage *image = [self createCellThumbnail: someImage]; UIImageView *thumbView = [[UIImageView alloc] initWithFrame: CGRectMake(150, -5, 55,55)]; thumbView.transform = CGAffineTransformMakeRotation(0.1f); thumbView.image = image; cell.clipsToBounds = NO; cell.contentView.clipsToBounds = NO; [cell.contentView addSubview: thumbView]; While the image will 'overflow' into the cell below it, the top of the image is always clipped, as demonstrated here: http://imgur.com/WDsAx . Does anyone know if what I'm trying to do is possible with the current approach or should I just figure out a way to draw these images onto the UITableView after all the cells are drawn (it's a non-scrollable tableview, so that would work and be fairly easy).

    Read the article

  • How do I prevent my platformer's character from clipping on wall tiles?

    - by Jonathan Hobbs
    Currently, I have a platformer with tiles for terrain (graphics borrowed from Cave Story). The game is written from scratch using XNA, so I'm not using an existing engine or physics engine. The tile collisions are described pretty much exactly as described in this answer (with simple SAT for rectangles and circles), and everything works fine. Except when the player runs into a wall whilst falling/jumping. In that case, they'll catch on a tile and begin thinking they've hit a floor or ceiling that isn't actually there. The player is moving right and falling downwards. So after movement, collisions are checked - and first, it turns out the player character is colliding with the tile 3rd from the floor, and pushed upwards. Second, he's found to be colliding with the tile beside him, and pushed sideways - the end result being the player character thinks he's on the ground and isn't falling, and 'catches' on the tile for as long as he's running into it. I could solve this by defining the tiles from top to bottom instead, which makes him fall smoothly, but then the inverse case happens and he'll hit a ceiling that isn't there when jumping upwards against the wall. How should I approach resolving this, so that the player character can just fall along the wall as it should?

    Read the article

  • IE7 is clipping my text. How do I adjust its attitude?

    - by Emiel
    Hi All, A few days ago I re-skinned my website, http://emle.nl. Development of this skin was primarily done using safari, and as expected, it all renders fine using firefox and opera. I've had to make a few small tweaks for IE7, but nothing much, except for one problem... The date indicators for a post are cut off in IE. This problem seems to occur only on nested span tags inside a left floating div. I think I need the floating div's in order to layout text on the left and the right side of the screen. Anyhow, I've summarized it into a small test case, located at http://emle.nl/test.html. In the different browsers, it looks like this. Of course safari and firefox get this right: Do any of you know how to stop IE7 from clipping my text? Edit: I have sort of given up on this problem. My scripts now check for IE7 and feed it somewhat simplified HTML that its limited engine can handle. It works in IE8, so, for now, just the special case for IE7 will have to do...

    Read the article

  • How do I controll clipping with non-opaque graphics-item's in Qt?

    - by JJacobsson
    I have a bunch of QGraphicsSvgItem's in a QGraphicsScene that are drawn connected by QGraphicsLineItem's. This show's a graph of a tree-structure. What I want to do is provide a feature where everything but a selected sub-tree becomes transparent. A kind of "highlight this sub-tree" feature. That part was easy, but the results are ugly because now the lines can be seen through the semi-transparent svg's. I am looking for some way to still clip other QGraphicsItem's in the scene to the svg item's, giving the effect that the svg's are semi-transparent windows to the background. I know this code does not use svg's but I figure you can replace that yourself if you are so inclined. int main(int argc, char *argv[]) { QApplication app(argc, argv); QGraphicsScene scene; for( int i = 0; i < 10; ++i ) { QGraphicsLineItem* line = new QGraphicsLineItem; line->setLine( i * 25.0 + 1.0, 0, i * 25.0 + 23.0, 0 ); scene.addItem( line ); } for( int i = 0; i < 11; ++i ) { QGraphicsEllipseItem* ellipse = new QGraphicsEllipseItem; ellipse->setRect( (i * 25.0) - 9.0, -9.0, 18.0, 18.0f ); ellipse->setBrush( QBrush( Qt::green, Qt::SolidPattern ) ); ellipse->setOpacity( 0.5 ); scene.addItem( ellipse ); } QGraphicsView view( &scene ); view.show(); return app.exec(); } I would like the line's to not be seen behind the circle's. I have tried fiddling with the depth-buffer and the stencil buffer using opengl rendering to no avail. How do I get the QGraphicsSvgItem's (or QGraphicsEllipseItem's in the example code) to still clip the lines even though they are semi-transparent?

    Read the article

  • UIImageView is clipping a pixel of the bottom of my UIImage...?

    - by akaii
    I'm not sure what might be causing this, but UIImageView occasionally clips off about a pixel or 2 from the bottom of some square/rectangular UIImages I'm using as subviews for UITableViewCells. These UIImageViews are well within the borders of the cell, so it shouldn't be due to cliptobounds. There seems to be no consistency or pattern to which images are being clipped, nor when they're clipped, other than that it only happens to (or is only noticable in) square/rectangular icons, and only ones that are parented to UITableViewCells (or their subclasses). I'm having trouble reproducing the problem consistently, which is why I haven't posted any code this time. Has anyone encountered something similar to this before? I've encountered a similar bug that involved floating point values for origin/size being interpreted weirdly... but that doesn't seem to be the cause of this particular problem. I don't need a specific solution at this point, I'm just making sure I haven't missed any well-known bugs or documented problems that involve UIImageView.

    Read the article

  • How do I stop IE6 clipping an element positioned outside its parent via negative margins?

    - by Paul D. Waite
    I have an element positioned outisde its parent via negative margins, like this: <style> .parent { height: 1%; } .element { float: left; margin-left: -4px; } </style> ... <div class="parent"> <div class="element">Element</div> </div> In Internet Explorer 6, the part of .element positioned outside of its parent element is clipped, i.e. invisible, hidden, cut off. How do I fix this?

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >