با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
فرمت تصویر Ultra HDR اطلاعات درخشندگی را رمزگذاری میکند که به دستگاهها اجازه میدهد تصاویر روشنتری با رنگهای شدیدتر نمایش دهند. وقتی برنامه شما یک تصویر Ultra HDR را ویرایش میکند، میخواهید مطمئن شوید که اطلاعات درخشندگی آن حفظ میشود. این مهم است حتی اگر دستگاه کاربر از نمایش تصویر Ultra HDR با شدت کامل پشتیبانی نکند. از این گذشته، کاربر ممکن است تصویر خود را با فردی با دستگاهی که از Ultra HDR پشتیبانی میکند به اشتراک بگذارد، یا ممکن است آن تصویر را ذخیره کند و سالها بعد دوباره در دستگاه جدیدی به آن نگاه کند.
خبر خوب این است که اکثر روش های اندروید برای ویرایش بیت مپ از فرمت تصویر Ultra HDR پشتیبانی می کنند. اگر در حال ویرایشهای اولیه یک تصویر هستید، مانند برش یا چرخش آن، روشهای استاندارد اندروید این کار را انجام میدهند—به یک تصویر فوقالعاده HDR با ابعاد یا جهتگیری جدید خواهید رسید.
اگر محتوای تصویر را تغییر دهید، کار دشوارتر است. در این موارد، روشهای ویرایش استاندارد، اطلاعات درخشندگی تصویر قدیمی را حفظ میکنند، که ممکن است آن چیزی نباشد که شما میخواهید. در این موارد، ممکن است لازم باشد نقشه افزایش (که اطلاعات درخشندگی تصویر را رمزگذاری میکند) را ویرایش یا حذف کنید تا به نتیجه مناسب برسید.
نمای کلی فرمت Ultra HDR
فرمت تصویر Ultra HDR با جزئیات در مشخصات تصویر Ultra HDR توضیح داده شده است. مهمترین چیزی که باید درک کنید این است که یک تصویر Ultra HDR هم شامل یک تصویر اصلی و هم یک نقشه افزایش است .
تصویر اصلی دارای اطلاعات رنگی برای هر پیکسل تصویر است.
نقشه بهره یک تصویر استاندارد JPEG با نسبت های مشابه با تصویر اصلی است، البته نه لزوماً همان ابعاد پیکسل. هر پیکسل از نقشه بهره، روشنایی قسمت مربوطه از تصویر اولیه را مشخص می کند.
نقشه بهره می تواند رنگ خاکستری یا رنگی باشد. اگر نقشه بهره رنگی باشد، هر کانال رنگی در نقشه بهره، درخشندگی آن کانال رنگی را در قسمت مربوطه از تصویر اصلی مشخص می کند. اگر نقشه افزایش مقیاس خاکستری باشد، هر پیکسل از نقشه بهره روشنایی هر سه کانال رنگی را در آن قسمت از تصویر اصلی مشخص می کند.
نقشه گین باید همان نسبت های تصویر اصلی را داشته باشد، اما لزومی ندارد که ابعاد پیکسل یکسانی داشته باشد. در واقع، زمانی که پلتفرم اندروید تصاویر Ultra HDR را ایجاد می کند، یک نقشه افزایش با عرض و ارتفاع کمتر از تصویر اصلی ایجاد می کند. با انجام این کار، اندازه فایل به طور قابل توجهی کوچکتر می شود، اما همچنان اطلاعات کافی برای یک نتیجه خوب را رمزگذاری می کند. این بدان معنی است که هر پیکسل در نقشه بهره ممکن است اطلاعات درخشندگی را برای چندین پیکسل در تصویر اولیه ذخیره کند.
ویرایش های اولیه Ultra HDR
اگر از API های Bitmap اندروید برای ایجاد تغییرات اساسی در یک تصویر Ultra HDR استفاده می کنید، روش ها تغییرات مناسبی را در نقشه بهره ایجاد می کنند. عملیات Bitmap زیر پشتیبانی می شود:
Rotate: اگر یک تصویر Ultra HDR را بچرخانید، این روش نقشه بهره را نیز می چرخاند.
برش: اگر یک تصویر Ultra HDR را برش دهید، این روش نقشه بهره را به طور مناسب برش می دهد.
مقیاس: اگر یک تصویر Ultra HDR را مقیاس کنید، این روش نقشه بهره را مقیاس میدهد تا نصف عرض و نیمی از ارتفاع تصویر اصلی تغییر اندازه داشته باشد.
در هر مورد، اطلاعات درخشندگی حفظ می شود.
ویرایش های پیشرفته Ultra HDR
اگر ویرایشهای دقیقتری روی یک تصویر Ultra HDR انجام دهید، نقشه بهره بدون تغییر حفظ میشود، که ممکن است نتایج دلخواه را به شما ارائه ندهد.
ویرایشهای رایجی که ممکن است در این وضعیت ایجاد شود عبارتند از:
افزودن برچسب یا ایموجی: برچسب اضافه شده همان مقدار درخشندگی و وضوح رنگ را دارد که روی آن چسبانده شده است.
همپوشانی تصویر دوم: تصویر جدید از اطلاعات درخشندگی و وضوح رنگ محتوایی که روی آن قرار میگیرد استفاده میکند.
افزودن فیلترها: اطلاعات نقشه بهره قدیمی ممکن است برای تصویر اولیه اصلاح شده مناسب نباشد.
در هر مورد، اطلاعات قدیمی درخشندگی و وضوح رنگ حفظ می شود، اما ممکن است برای تصویر اصلاح شده مناسب نباشد.
اگر نقشه اصلی برای تصویر ویرایش شده مناسب است، لازم نیست کاری انجام دهید. اگر می خواهید نقشه بهره را تغییر دهید، گردش کار معمول به این صورت است:
با فراخوانی Bitmap.getGainmap()نقشه بهره فعلی تصویر را واکشی کنید و آن را کش کنید.
تصویر اصلی را به دلخواه تغییر دهید.
ویرایش های مربوطه را در نقشه کش ذخیره شده انجام دهید. برای مثال، اگر یک ایموجی را روی تصویر اصلی چسباندهاید، میتوانید قسمت مربوطه از نقشه افزایش را روی یک مقدار خنثی تنظیم کنید، مانند Color.GRAY .
با فراخوانی Bitmap.setGainmap()نقشه افزایش اصلاح شده را روی تصویر اعمال کنید .
منابع اضافی
برای کسب اطلاعات بیشتر در مورد تصاویر Ultra HDR، به منابع اضافی زیر مراجعه کنید:
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-08-27 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-08-27 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Edit Ultra HDR images\n\nThe [Ultra HDR image format](/guide/topics/media/platform/hdr-image-format) encodes luminosity information\nthat lets devices display brighter\nimages with more intense colors. When your app edits an Ultra HDR image, you\nwant to make sure to preserve that luminosity information. This is important even if the\nuser's device doesn't support displaying an Ultra HDR image at full\nintensity. After all, the user might share their image to someone with a device\nthat supports Ultra HDR, or they might save that image and look at it again on a\nnew device years later.\n\nThe good news is most Android methods for editing bitmaps support the Ultra HDR\nimage format. If you're making basic edits to an image, like cropping or\nrotating it, the standard Android methods do the job---you'll end up with an\nultra HDR image with the new dimensions or orientation.\n\nThe job is trickier if you're modifying the contents of the image. In those\ncases, the standard editing methods preserve the luminosity information of the\n*old* image, which might not be what you want. In those cases, you might need to\nedit or remove the gain map (which encodes the image's luminosity information)\nto get the right result.\n\n### Ultra HDR format overview\n\nThe Ultra HDR image format is described in detail in the [Ultra HDR Image\nspecification](/guide/topics/media/platform/hdr-image-format). The most important thing to understand is an\nUltra HDR image contains both a *primary image* and a *gain map*.\n\n- The *primary image* has the color information for each pixel of the image.\n- The *gain map* is a standard JPEG image with the same proportions as the primary image, though not necessarily the same pixel dimensions. Each pixel of the gain map specifies the luminance of the corresponding part of the primary image.\n\nThe gain map can be either grayscale or color. If the gain map is in color, each\ncolor channel on the gain map specifies the luminance of that color channel on\nthe corresponding part of the primary image. If the gain map is grayscale, each\npixel of the gain map specifies the luminance of all three color channels on\nthat portion of the primary image.\n\nThe gain map must have the same proportions as the primary image, but it does\nnot have to have the same pixel dimensions. In fact, when the Android platform\ncreates Ultra HDR images, it creates a gain map with a smaller width and height\nthan the primary image; doing so makes the file size significantly smaller, but\nstill encodes enough information for a good result. This means that each pixel\nin the gain map might store the luminance information for several pixels in the\nprimary image.\n\n### Basic Ultra HDR edits\n\nIf you use the Android [`Bitmap`](/reference/android/graphics/Bitmap) APIs to make\nbasic transformations to an Ultra HDR image, the methods make the appropriate\nchanges to the gain map. The following `Bitmap` operations are supported:\n\n- **Rotate:** If you rotate an Ultra HDR image, the method rotates the gain map too.\n- **Crop:** If you crop an Ultra HDR image, the method crops the gain map appropriately.\n- **Scale:** If you scale an Ultra HDR image, the method scales the gain map so it has half the width and half the height of the resized primary image.\n\nIn each case, the luminosity information is preserved.\n\n### Advanced Ultra HDR edits\n\nIf you make more elaborate edits to an Ultra HDR image, the gain map is\npreserved unchanged, which may not give you the results you want.\n\nCommon edits that might result in this situation include:\n\n- **Adding stickers or emoji:** The added sticker would have the same luminosity and color vividness values as the area it was pasted on.\n- **Overlaying a second image:** The new image would use the luminosity and color vividness information of the content it's overlaying.\n- **Adding filters:** The old gain map's information might not be appropriate for the modified primary image.\n\nIn each case, the old luminosity and color vividness information is preserved,\nbut it might not be appropriate for the modified image.\n\nIf the original gain map is appropriate for the edited image, you don't have to\ndo anything. If you *do* want to modify the gain map, the usual workflow is:\n\n1. **Fetch the image's current gain map** by calling [`Bitmap.getGainmap()`](/reference/android/graphics/Bitmap#getGainmap()) and cache it.\n2. **Modify the primary image as desired.**\n3. **Make corresponding edits to the cached gain map.** For example, if you\n pasted an emoji onto the primary image, you might set the corresponding\n portion of the gain map to a neutral value, like [`Color.GRAY`](/reference/android/graphics/Color#GRAY).\n\n | **Important:** The gain map might not have the same pixel dimensions as the primary image. For this reason, you need to calculate the appropriate pixels on the gain map that correspond to the edited areas on the primary image. For example, suppose the primary image is 8,000×4,000 pixels, and the gain map is 2,000×1,000 pixels. If you edit pixel (500,600) on the primary image, the corresponding pixel on the gain map would be at location (125,150).\n4. **Apply the modified gain map back to the image** by calling\n [`Bitmap.setGainmap()`](/reference/android/graphics/Bitmap#setGainmap(android.graphics.Gainmap))).\n\n### Additional resources\n\nTo learn more about Ultra HDR images, see the following additional resources:\n\n- [Ultra HDR image format specification](/guide/topics/media/platform/hdr-image-format)"]]