Accessing the document object of a frame with JavaScript

The all-around way to getting a frame’s contents is with something like this: var theFrame = document.getElementsByTagName(“frame”)[0]; var theFrameDocument = theFrame.contentDocument || theFrame.contentWindow.document; var button = theFrameDocument.getElementById(“mybutton”); However, it is possible to get a <frame>‘s document by using its name, like: window.frames[“frame_name”].document if the HTML were: <frame name=”frame_name”>…</frame>

How do you do transition effects using the Frame control in WPF?

There is a similar problem discussed here: Transition Fade Animation When Navigating To Page Using the technique described there you can slide\move your frame control each time a new page is navigated. Smth like this: xaml: … <Frame Name = “frame” Navigating=”frame_Navigating”> … code: … private bool _allowDirectNavigation = false; private NavigatingCancelEventArgs _navArgs = null; … Read more

Get width of a view using in SwiftUI

The only available mechanism to get the dimension of a view, that is auto-resized by SwiftUI, is the GeometryReader. The GeometryReader is a proxy view that returns the dimensions of the container in which your view gets rendered. struct SomeView: View { @State var size: CGSize = .zero var body: some View { VStack { … Read more

Converting preview frame to bitmap

Alternatively, if you DO need a bitmap for some reason, and/or want to do this without creating a YUVImage and compressing to JPEG, you can use the handy RenderScript ‘ScriptIntrinsicYuvToRGB’ (API 17+): @Override public void onPreviewFrame(byte[] data, Camera camera) { Bitmap bitmap = Bitmap.createBitmap(r.width(), r.height(), Bitmap.Config.ARGB_8888); Allocation bmData = renderScriptNV21ToRGBA8888( mContext, r.width(), r.height(), data); bmData.copyTo(bitmap); … Read more

Custom MKAnnotation callout bubble with button

There are several approaches to customizing callouts: The easiest approach is to use the existing right and left callout accessories, and put your button in one of those. For example: – (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { static NSString *identifier = @”MyAnnotationView”; if ([annotation isKindOfClass:[MKUserLocation class]]) { return nil; } MKPinAnnotationView *view = (id)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier]; if … Read more

Simple way to change the position of UIView?

aView.center = CGPointMake(150, 150); // set center or aView.frame = CGRectMake( 100, 200, aView.frame.size.width, aView.frame.size.height ); // set new position exactly or aView.frame = CGRectOffset( aView.frame, 10, 10 ); // offset by an amount Edit: I didn’t compile this yet, but it should work: #define CGRectSetPos( r, x, y ) CGRectMake( x, y, r.size.width, r.size.height … Read more

android capture video frame

The following works for me: public static Bitmap getVideoFrame(FileDescriptor FD) { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); try { retriever.setDataSource(FD); return retriever.getFrameAtTime(); } catch (IllegalArgumentException ex) { ex.printStackTrace(); } catch (RuntimeException ex) { ex.printStackTrace(); } finally { try { retriever.release(); } catch (RuntimeException ex) { } } return null; } Also works if you use a … Read more