1. <tfoot id='Nc05u'></tfoot>
  2. <legend id='Nc05u'><style id='Nc05u'><dir id='Nc05u'><q id='Nc05u'></q></dir></style></legend>
  3. <small id='Nc05u'></small><noframes id='Nc05u'>

      <bdo id='Nc05u'></bdo><ul id='Nc05u'></ul>
    <i id='Nc05u'><tr id='Nc05u'><dt id='Nc05u'><q id='Nc05u'><span id='Nc05u'><b id='Nc05u'><form id='Nc05u'><ins id='Nc05u'></ins><ul id='Nc05u'></ul><sub id='Nc05u'></sub></form><legend id='Nc05u'></legend><bdo id='Nc05u'><pre id='Nc05u'><center id='Nc05u'></center></pre></bdo></b><th id='Nc05u'></th></span></q></dt></tr></i><div id='Nc05u'><tfoot id='Nc05u'></tfoot><dl id='Nc05u'><fieldset id='Nc05u'></fieldset></dl></div>

      组合多个 UIImageViews 并保留分辨率

      Combining multiple UIImageViews and preserve resolution(组合多个 UIImageViews 并保留分辨率)

        1. <small id='02lkC'></small><noframes id='02lkC'>

            <bdo id='02lkC'></bdo><ul id='02lkC'></ul>

                <tbody id='02lkC'></tbody>
                <tfoot id='02lkC'></tfoot>
                <i id='02lkC'><tr id='02lkC'><dt id='02lkC'><q id='02lkC'><span id='02lkC'><b id='02lkC'><form id='02lkC'><ins id='02lkC'></ins><ul id='02lkC'></ul><sub id='02lkC'></sub></form><legend id='02lkC'></legend><bdo id='02lkC'><pre id='02lkC'><center id='02lkC'></center></pre></bdo></b><th id='02lkC'></th></span></q></dt></tr></i><div id='02lkC'><tfoot id='02lkC'></tfoot><dl id='02lkC'><fieldset id='02lkC'></fieldset></dl></div>
              1. <legend id='02lkC'><style id='02lkC'><dir id='02lkC'><q id='02lkC'></q></dir></style></legend>
                本文介绍了组合多个 UIImageViews 并保留分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在设计一个应用程序,其中用户将多个 UIImageView 一个接一个地放置.当用户决定将其保存到相册时,我必须将所有这些 UIImageViews 组合起来并将其保存到照片库中.在组合它们时,我需要保留它们的位置、分辨率、zorder.我尝试过的方法是拥有一个类似于容器的父 UIView.用户将所有 UIImageViews 放在这个 UIView 中.保存时,我截取 UIView 的屏幕截图并保存.尽管这种方法有效,但它不保留分辨率.最终图像的分辨率与父 UIView 大小的分辨率相同(宽度和高度均为 300 像素).有没有办法保留分辨率?或者至少有更高的分辨率,比如高达 1024 x 768 像素?任何指针/代码示例将不胜感激!

                I am designing an application where a user places multiple UIImageViews one over another. When the user decides to save this to photo album, I have to combine all these UIImageViews and save it to Photo Library. While combining them I need to preserve their positions, resolutions, zorder. The approach I tried I was to have a parent UIView which acts like a container. The user places all the UIImageViews inside this UIView. While saving, I take a screenshot of the UIView and save it. Although this approach works, it does not preserve the resolution. The resolution of the final image is same as the resolution of the parent UIView size (width and height being 300 pixels). Is there way to preserve the resolution? or atleast have a higher resolution like upto 1024 x 768 pixels? Any pointers/code examples would be appreciated!

                推荐答案

                如果 UIView 的大小高于您拥有的最大图像的大小,那么您正在做的事情,保存 UIView 是一个非常好的主意,但是几乎从来没有这样.您需要做的是创建一个图形上下文 (CGContextRef),与最大的图像一样大,按 z 顺序对图像进行排序并开始在那里绘制这些图像.我会尝试用一些伪代码来帮助你:

                What you are doing, saving the UIView, is a very good idea if the size of the UIView is higher than the size of the biggest image you have, but that's almost never the case. What you have to do is to create a Graphic Context (CGContextRef), as big as the biggest of your images, sort your images by z-order and start drawing those images there. I'll try to help you with some pseudo code:

                -(UIImage *)mergeFlag{
                
                UIImage * mergedImage = nil;
                
                //In some pace you need to fill these values with the biggest width of all your images and the biggest height;
                int Max_Width;
                int Max_Height;
                
                //Use here your image with the biggest Z-order.
                CGImageRef image;
                
                size_t cWitdh = Max_Width;
                size_t cHeight = Max_Height;
                size_t bitsPerComponent = 8;//If 8 isn't right you should use CGImageGetBitsPerComponent(image) with some image.
                size_t bytesPerRow = 4 * Max_Width;// I use 4 assuming you have 8 Bits per component and you have 4 components (R,G,B,A) , if you have an image specifically, you can use CGImageGetBytesPerRow(image)
                
                //Now we build a Context with those dimensions.
                CGContextRef context = CGBitmapContextCreate(nil, cWitdh, cHeight, bitsPerComponent, bytesPerRow, CGColorSpaceCreateDeviceRGB(), CGImageGetBitmapInfo(image));
                
                //The code of this cycle is to ilustrate what you have to do:
                for(image in your Images ordered by z-Order)
                {
                    //The location where you draw your image on the context is not always the same location you have in your UIView, 
                    //this could change and you need to calculate that position according to the scale between you images real size, and the size of the UIImage being show on the UIView.
                    CGContextDrawImage(context, CGRectMake(currentImage.frame.origin.x, currentImage.frame.origin.y, CGImageGetWidth(currentImage), CGImageGetHeight(currentImage), currentImage);
                }
                
                CGImageRef mergeResult  = CGBitmapContextCreateImage(context);
                mergedImage = [[UIImage alloc] initWithCGImage:tmp];
                CGContextRelease(context);
                CGImageRelease(mergeResult);
                return mergedImage;}
                

                希望对你有帮助.

                这篇关于组合多个 UIImageViews 并保留分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                WebKit on th iPhone: is it possible to copy text to the clipboad with JavaScript(iPhone上的WebKit:是否可以使用JavaScript将文本复制到剪贴板)
                When compiling for multiple targets in XCode, how do i ensure that certain files will not be included one target(在 XCode 中为多个目标编译时,我如何确保某些文件不会包含在一个目标中)
                Selecting text in mobile Safari on iPhone(在 iPhone 上的移动 Safari 中选择文本)
                Create UIImage cutout(创建 UIImage 抠图)
                Draggable UIImageView Partially Transparent amp; Irregular Shaped(可拖动的 UIImageView 部分透明 amp;不规则形状)
                How to set the resolution of a saved image from the UIImagePickerController(如何从 UIImagePickerController 设置保存图像的分辨率)
                  <bdo id='VR52e'></bdo><ul id='VR52e'></ul>
                    <tbody id='VR52e'></tbody>

                  <small id='VR52e'></small><noframes id='VR52e'>

                  <legend id='VR52e'><style id='VR52e'><dir id='VR52e'><q id='VR52e'></q></dir></style></legend><tfoot id='VR52e'></tfoot>
                    • <i id='VR52e'><tr id='VR52e'><dt id='VR52e'><q id='VR52e'><span id='VR52e'><b id='VR52e'><form id='VR52e'><ins id='VR52e'></ins><ul id='VR52e'></ul><sub id='VR52e'></sub></form><legend id='VR52e'></legend><bdo id='VR52e'><pre id='VR52e'><center id='VR52e'></center></pre></bdo></b><th id='VR52e'></th></span></q></dt></tr></i><div id='VR52e'><tfoot id='VR52e'></tfoot><dl id='VR52e'><fieldset id='VR52e'></fieldset></dl></div>