packing

Pack four bytes in a float

眉间皱痕 提交于 2019-12-14 00:19:36
问题 I'm writing a shader (HLSL), and I need to pack a color value into the R32 format. I've found various pieces of code for packing a float into the R8G8B8A8 format, but none of them seem to work in reverse. I'm targeting SM3.0, so (afaik) bit operations are not an option. To sum it up, I need to be able to do this: float4 color = ...; // Where color ranges from 0 -> 1 float packedValue = pack(color); Anyone know how to do this? UPDATE I've gotten some headway... perhaps this will help to

Javascript Packing with many constraints, looking for a simple solution

亡梦爱人 提交于 2019-12-13 05:36:27
问题 This is not exactly packing as I can assign rectangle sizes myself, I just need a packed result. I have rectangles of same ratio and different sizes FULL, HALF(area = 1/4 * FULL), QUARTER(area = 1/4 * HALF). All will be positioned horizontally only. The container is of width 3 times FULL and height will adjust to fit rectangles. There will be 150 rectangles which will be given random sizes from array(full,half,quarter). Now I want to arrange these rectangles in the container so that there is

Packing items into fixed number of bins

社会主义新天地 提交于 2019-12-12 11:05:01
问题 I am looking for an algorithm that will solve my problem in the most efficient way. Problem description: I have a list of items (only positive integers are allowed) and fixed number of bins of identical capacity. So far, I thought about branch-and-bound algorithm, but I am not quite sure if it is the best approach in this case. Example: Given a list of items: (3, 4, 4, 2, 3, 9, 2) and three bins of capacity 9 each I need to pack them this: (order of items is irrelevant) [3, 4, 2], [4, 3, 2],

Getting different header size by changing window size

微笑、不失礼 提交于 2019-12-12 10:38:19
问题 I have a C++ program representing a TCP header as a struct: #include "stdafx.h" /* TCP HEADER 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Source Port | Destination Port | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Sequence Number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Acknowledgment Number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

How to pack a hexadecimal value in an unsigned char variable in a C program?

瘦欲@ 提交于 2019-12-11 03:14:33
问题 I have a hexadecimal value "F69CF355B6231FDBD91EB1E22B61EA1F" in a string and I am using this value in my program by hardcoding the value in an unsigned char variable like this: unsigned char a[] = { 0xF6 ,0x9C ,0xF3 ,0x55 ,0xB6 ,0x23 ,0x1F ,0xDB ,0xD9 ,0x1E ,0xB1 ,0xE2 ,0x2B ,0x61 ,0xEA ,0x1F}; Is there any function or any other method by which I can take the value from a string and put it into an unsigned variable in the hexadecimal format by packing it? 回答1: #include <stdio.h> #include

Can someone explain Gtk2 packing?

廉价感情. 提交于 2019-12-11 02:07:35
问题 I need to use Gtk2 for a project. I will be using python/ruby for it. The problem is that packing seems kind of mystical to me. I tried using a VBox so that I could have the following widgets in my window ( in the following order ): menubar toolbar text view/editor control I've managed to "guess" my way with pack_start and get the layout I need, but I'd like to be able to understand it. The documentation at Ruby Gtk2 seems way too unintuitive (and so is the python one, since it's the same,

Bin Packing - Brute force recursive solution - How to make it faster

隐身守侯 提交于 2019-12-09 01:06:00
问题 I have an array which contains a list of different sizes of materials : {4,3,4,1,7,8} . However, the bin can accomodate materials upto size 10. I need to find out the minimum number of bins needed to pack all the elements in the array. For the above array, you can pack in 3 bins and divide them as follows: {4,4,1} , {3,7} , {8} . There are other possible arrangements that also fit into three stock pipes, but it cannot be done with fewer I am trying to solve this problem through recursion in

Hints with same-rectangles-in-rectangle packing algorithm with guillotine limitation?

我的未来我决定 提交于 2019-12-08 08:04:07
问题 I've been tasked with building a program for an acquaintance, that calculates the best way to fit book pages on a large paper to be printed and cut. In practice, that means I need to find the best way to arrange rectangles with identical dimensions (the pages) inside a given rectangle (the printing paper) in such a way that guillotine cuts can be used to separate all pages without ruining any. If any of you can point my searches to a better direction, either by giving me links or a more

Hints with same-rectangles-in-rectangle packing algorithm with guillotine limitation?

心已入冬 提交于 2019-12-06 15:08:38
I've been tasked with building a program for an acquaintance, that calculates the best way to fit book pages on a large paper to be printed and cut. In practice, that means I need to find the best way to arrange rectangles with identical dimensions (the pages) inside a given rectangle (the printing paper) in such a way that guillotine cuts can be used to separate all pages without ruining any. If any of you can point my searches to a better direction, either by giving me links or a more accurate wording of the problem's name (terminology-wise), that would be great. I've narrowed the

Any tools available for packing 32bit/64bit executables together? [closed]

岁酱吖の 提交于 2019-12-05 22:47:27
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I really like the way the SysInternals utilities (e.g. Process Explorer) handle 64bit compatibility. It looks like the 32bit executable has the 64bit version embedded in it, and extracts it if necessary. I'd like a tool which automates this - i.e. takes 32bit and 64bit executables, packs them together somehow,