|
I have recently discovered that
dc.SelectObject(&mybitmap);
...
dc.SelectObject((CBitmap*)NULL);
does not cause the release of mybitmap.
What is the proper way to cause dc to release bitmap without assigning another "real" resource (return the dc to its freshly created state) so that another dc in another subroutine can select mybitmap?
Tadeusz Westawic
Sum quid sum.
|
|
|
|
|
The first call to SelectObject will have returned a handle to the default bitmap in the DC. Store it and select it back in when you're finished.
L u n a t i c F r i n g e
|
|
|
|
|
Yes, thank you, it is the way I used to do it.
Let me ask this, then: what does the dc.SelectObject() doc (msdn) mean in explanation of return value, where it says about func may return ptr to temp object?
That is the thing that scared me off the tried and true.
Tadeusz Westawic
Sum quid sum.
|
|
|
|
|
See here[^], if you haven't already.
L u n a t i c F r i n g e
|
|
|
|
|
GDI works with handles: HDC for device-contexts, HBITMAP for bitmaps, and so on.
MFC provides a wrapper class for each entity provided by GDI: the CDC class wraps a device-context and internally holds an HDC , the CBitmap class wraps a bitmap and internally holds an HBITMAP and so on.
When you call CDC::SelectObject() , it returns a pointer to the appropriate MFC class that represents the GDI object previously selected into the device-context; these pointers are obtained calling the FromHandle() method (e.g. in case of a bitmap object CBitmap::FromHandle() is called).
The pointers obtained in this way could be temporary because, if your application reach the idle state, i.e. its CWinApp::OnIdle() is called, the objects pointed are deleted; this doesn't mean that the underlaying handle is destroyed, but only that the wrapper class is destroyed. As a conseguence, you cannot store such a pointer to use it later: you should select it back into the device-context before returning from the current message handler.
|
|
|
|
|
That is a great answer; I now understand completely.
Thank You
Tadeusz Westawic
Sum quid sum.
|
|
|
|
|
using the sharelist API we can using the same list in diffrent RC, but how can the diffrent DC share the same OpenGL List? thanks 
|
|
|
|
|
Asking the same question twice in a row is not considered appropriate in the CP forums. If you don't get an answer, maybe you should consider modifying your question.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
as far as opengl is concerned it just execut the opengl commands to the active context.for a single thread we can have only one active context.u can create a context using wglCreateContext function.
to make it active u need to call wglMakeCurrent.
so u can swith DCs by calling wglMakeCurrent function.
if u need to draw simultaneously to two DCs u need to have two threads.
If u can Dream... U can do it
|
|
|
|
|
diffrent RC can share the same openGL list, but can diffrent DC share the same list?
thanks 
|
|
|
|
|
A display list could be shared between multiple rendering context; it doesn't matter the device context to which each HRC is related. Then the answer is yes.
|
|
|
|
|
Please help find the source of the program determine authenticity photos ......
I saw it on the site, but forgot her path.
|
|
|
|
|
Hello,
I found the following code to create a MultiFrame image in C#[^] and used it on 3 jpeg files. The file sizes were 96 KB, 103 KB and 82 KB. However, the output file was 2.7 MB.
It seems like the process is decompressing the jpegs or something. I tried to add another parameter to set the quality, but I really don't want to decrease the quality or change the dimensions.
I'm basically trying to find the simplest methods to put the images into an "archive" that I can then read and separate the images at a later time. I don't want to use zip files. I just want to append all images and read them back via offsets and a binary reader and then display the images in a picture box. I'd like to also store these offsets in the output file as some sort of "header" record if possible. I'm trying to keep it simple and the output file size around the same size as the originals.
Any thoughts here on the MultiFrame size issue or a sample of how to create a some "archive"?
Thanks,
Chris
|
|
|
|
|
If you read the documentation accompanying the sample, it says bitmaps are created from the supplied images and then saved in a tiff format; so yes, the images are decompressed before saving. (Tiff supports various compression schemes, but the sample doesn't give any details as to the particulars of the tiff encoder, and the result implies compression of the tiff was minimal, if employed at all.)
If you're just trying to save the original images into a signle 'archive' file, just open a binary file and write the images into it, one after another. That'll preserve whatever encoding/compression scheme was used in the original image files. It'll be up to you to maintain some sort of index data giving file sizes and/or offsets into the binary archive so you can pull individual images out when you want. As you say, you could create a data structure for this purpose and put it at the head of the file where it'd be read first. Make the first member in the structure the number of images it contains, followed by size and offset for each individual image contained in the archive. It should be fairly simple to implement this, once you've worked out the details of your desired scheme.
L u n a t i c F r i n g e
|
|
|
|
|
Ah, the old RTFM gotcha. Oops! I really need to pay closer attention. LOL
Yeah, I just decoder to append the images together, which keeps the size close. Now i'm just trying to work out saving off the indexes in the same file.
Thanks for bringing that to my attention.
Chris
|
|
|
|
|
glut provide some API to draw sphere such as glutSolidSphere and glutwireSphere. I want to draw 3D earth with diffrent resolution texture like google earth. but the glut API can not realize, where can i find some useful knowledge about it? thanks 
|
|
|
|
|
Hi,
I have a list of colors (with RGB value and name). I need to sort them according to the RGB. The list is expected as linear (1 dimensional). Sorting means, similar color (for eg., shades of blue) should come nearby. From googling I found that CIELAB color space is better to use for this. But even though I converted to CIELAB and do a lot of experiments, I couldn't sort successfully.
If you have some suggestions or guidelines please share.
Thank you.
- ns ami -
|
|
|
|
|
I don't think there is a really good solution to your quest. First of all you have to decide what order you really want. If you have 6 colors (dark green, light green, dark blue, light blue, dark red, light red), what would you want as a result? Once you decided that, it wouldn't be too hard to implement it; the probable approach is giving each color a numeric value which probably would be calculated from two color aspects, e.g. 256 * hue + saturation (each aspect assumed to be between 0 and 255). However I can't imagine a good order for the example given earlier.
|
|
|
|
|
Thank you for your reply.
As you mentioned, the order can be based on hue. I have already done some experiments with that. If we use HSV or HSL color model, and then the priority is as hue > sat > val/lum, still the order was not satisfying. Then I tried CIELAB, but have no idea on how to sort the colors in this color space. In some sites, it is said that this color space is best for our (human) perspective.
I just want to get an order in the appearance of colors. I doubt, it is not so easy to sort and list the colors in one dimension. Trying again and again...
- ns ami -
|
|
|
|
|
Currently I try to find a library/framework/component to develop a page layout tool.
It should provide a framework to build a custom appplication.
The user should be able to define a page from pre-defined components like text-boxes and graphics. The display should be the preview of the page like it will be printed (wysiwyg). The user should be able to arrange/resize the components on the page and edit and format the contents of the text boxes. In-place editing of the text twould be nice.
Does anyone know a library (open-source or commercial) which provides those basic capabilities in C++/MFC or COM. So far I could not find suitable libraries.
|
|
|
|
|
Windows XP/Vista/7
Microsoft Directx SDK (February 2010)
Borland C++ 6.0
#include <SpecStrings.h>
#include <d2d1.h>
#include <d2d1helper.h>
....
Whats the error
[C++ Error] d2d1helper.h(193): E2034 Cannot convert 'const D2D_POINT_2F' to 'float'
|
|
|
|
|
|
There are no other kods - 3 #include lines only.
D2DBaseType.h :
typedef struct D2D_POINT_2F
{
FLOAT x;
FLOAT y;
} D2D_POINT_2F;
---
d2d1.h :
typedef D2D_POINT_2F D2D1_POINT_2F;
typedef struct
{
D2D1_POINT_2F point;
D2D1_SIZE_F size;
FLOAT rotationAngle;
D2D1_SWEEP_DIRECTION sweepDirection;
D2D1_ARC_SIZE arcSize;
} D2D1_ARC_SEGMENT;
---
d2d1helper.h :
D2D1FORCEINLINE
D2D1_ARC_SEGMENT
ArcSegment(
__in CONST D2D1_POINT_2F &point,
__in CONST D2D1_SIZE_F &size,
__in FLOAT rotationAngle,
__in D2D1_SWEEP_DIRECTION sweepDirection,
__in D2D1_ARC_SIZE arcSize
)
{
D2D1_ARC_SEGMENT arcSegment = { point, size, rotationAngle, sweepDirection, arcSize };
return arcSegment;
}
The main difference in structure D2D1_ARC_SEGMENT -> D2D1_POINT_2F point;
and ArcSegment(
__in CONST D2D1_POINT_2F &point,
...
It should be critical -> point and &point 
|
|
|
|
|
The error here is that you have a point value, and you are trying to cast a single float. A point consists of 2 values, both of which must be supplied. Fill it with
myD2DRef.x = x;
myD2DRef.y = y;
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi, i have seen, that WPF is not the way to go for my app due to performace limitations, so i will use DirectX directly instead. But:
1.) Is it a problem to render different FontFamilies?
2.) Direct2D uses geometries wich can be combined. Can i resolve this function in Direct3D easily, too?
3.) What about printing (the printout is bigger as the visual part on the screen). Can i render the hole scene to a huge bitmap for example, which i can print?
|
|
|
|