Hi !!
To draw multiple graphics objects which have different shapes, I’m using
the region class to exclude/union the drawing area of these Objects.
The rectangle around a single object is of the size of 80x80 pixels. So
looping through these pixels and excluding the area of every transparent
pixel, the region will be built.
Afterwards, such an object has a memory usage of approx. 700Kb (before
modifying the region it was nearly 300kb).
So can anybody tell me, how to provide Objects with transparent
background and also keeping the memory usage low.
A weblink to more information about this region class would also be
helpful.
Thanks in advance,
Martin.
PS: Special thanks to Tom Overbay who provided me with the first code to
create user icons.
Here is a code snippet to show, what the program does:
For y = 0 To MyBitmap.Height - 1
For x = 0 To MyBitmap.Width - 1
' Exclude alpha pixels
If MyBitmap.GetPix el(x, y).A = 0 Then
MyRegion.Exclud e(New Rectangle(x, y, 1, 1))
End If
Next
Next
..
..
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! 5 1765
Hello,
"Martin Wolff" <ma***@111.co m> schrieb: The rectangle around a single object is of the size of 80x80 pixels. So looping through these pixels and excluding the area of every transparent pixel, the region will be built.
Afterwards, such an object has a memory usage of approx. 700Kb (before modifying the region it was nearly 300kb).
You are right -- "complex" regions need a lot of memory.
So can anybody tell me, how to provide Objects with transparent background and also keeping the memory usage low.
Sorry, I don't have a sample, but why not drawing everything onto one
control? You can safe parts of the image in separate buffers and restore
them when moving objects.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET http://www.mvps.org/dotnet
Herfried,
thank you for your fast answer and your suggestion. But I think that
won't be the fine OOP way.
I prefer to have the objects doing their stuff themself. The handling
will be much easier when copying or deleting such a symbol, if they have
all the information close to them.
Will the memory usage go down, if I combine empty pixels to a bigger
rectangle before excluding them ?
Thanks in advance,
regards,
Martin.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Martin,
In addition to Herfried's comments.
Would it be easier to define the 'shape' in terms of a GraphicsPath object?
Rather then checking bits on the bitmap, draw the shape onto the
GraphicsPath to begin with?
Or are you actually reading the bitmaps from files rather than creating
them?
According to Charles Petzold in "Programmin g Microsoft Windows with
Microsoft Visual Basic.NET"
"With the introduction of paths, regions have become much
less important in Windows graphics programming.
They might even be ignored altogether if not for the role
they play in clipping"
I normally start with a GraphicsPath then convert it into a Region, only
when I need it as a Region. For the clipping region for example.
Does the Clone method of the Region return a more compact Region?
Hope this helps
Jay
"Martin Wolff" <ma***@111.co m> wrote in message
news:uX******** ******@TK2MSFTN GP09.phx.gbl... Hi !!
To draw multiple graphics objects which have different shapes, I'm using the region class to exclude/union the drawing area of these Objects.
The rectangle around a single object is of the size of 80x80 pixels. So looping through these pixels and excluding the area of every transparent pixel, the region will be built.
Afterwards, such an object has a memory usage of approx. 700Kb (before modifying the region it was nearly 300kb).
So can anybody tell me, how to provide Objects with transparent background and also keeping the memory usage low.
A weblink to more information about this region class would also be helpful.
Thanks in advance,
Martin.
PS: Special thanks to Tom Overbay who provided me with the first code to create user icons. Here is a code snippet to show, what the program does:
For y = 0 To MyBitmap.Height - 1 For x = 0 To MyBitmap.Width - 1 ' Exclude alpha pixels If MyBitmap.GetPix el(x, y).A = 0 Then MyRegion.Exclud e(New Rectangle(x, y, 1, 1)) End If Next Next . .
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
Hi Martin,
I'm confused by your numbers. An 80 x 80 x 4 (true colour) image is only
25600 bytes. How do you get to the 300K region, let alone 700K?? Was 80x80 a
type?
One thing is certain however, your current method is very costly per
pixel. It creates a 1x1 Rectangle (16 bytes) and adds that to a Region.
Assuming that the Region doesn't merge its rectangles, it needs to store its
Rectangles in some data structure. This would need memory allocation requiring
at least another 8 bytes, probably more. All this is per pixel!
Jay's idea of using a GraphicsPath would make it much more efficient
(assuming, of course, that much of these excluded pixels are contiguous).
If you are starting with a bitmap, there are a number of methods for
creating larger regions, and for creating completely enclosed areas, suitable
for representation using a GraphicsPath.
At the very least, rather than adding pixels to the region separately, you
could do horizontal scans and collect runs of pixels. A further step would be
to take a series of such runs (line 1, line 2, etc), and determine whether and
how they overlap vertically. These could then be converted to blocks plus bits
of runs, or, better, into a single GraphicsPath region.
Come back if you need more help on this. :-)
Regards,
Fergus
Thank you Jay and Fergus,
I will try to use GraphicsPath instead of the Region, if this will
provide me a transparency too.
Regards,
Martin.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Altramagnus |
last post by:
I have a complicated Region object, which I need to draw the outline, but
not fill
How can I convert the Region object to GraphicsPath object?
or How can I draw the outline of the Region object?
|
by: dm1608 |
last post by:
I have an Ecommerce application that uses mostly ASP and a bit of ASP.NET.
Monitoring the servers memory via SNMP every 5 minutes would indicate that
there is a memory leak somewhere within the application. Of course, the
vendor says its a "Microsoft IIS" issue and tells us to reboot the server
each day or kill the worker process for IIS.
We're currently rebooting our server at 4 AM each night.
This is a really lame idea, in my...
|
by: Tim Marshall |
last post by:
HI folks,
I'm doing an app that requires the user to be able to choose a country,
then a state/province/territory, then a city and possibly somewhere
in-between, some kind of region, perhaps county or geographic region.
Are there any resources anyone may know out there where I can harvest
such information?
--
Tim http://www.ucs.mun.ca/~tmarshal/
|
by: Ajai Jose |
last post by:
Hi ,
I work on an ARM processor based embedded system. Code is mainly in
C language. The project has a huge source base. We are supposed to
optimise it. Most datastructures are declared as static and which
directly go into the Zero Initialised region. We need to cut the size
of this ZI region by at least 30%.
The one way i see of doing this is by removing these static arrays
and passing a pointer to the data structure whenever required....
|
by: robert maas, see http://tinyurl.com/uh3t |
last post by:
I'm working on examples of programming in several languages, all
(except PHP) running under CGI so that I can show both the source
files and the actually running of the examples online. The first
set of examples, after decoding the HTML FORM contents, merely
verifies the text within a field to make sure it is a valid
representation of an integer, without any junk thrown in, i.e. it
must satisfy the regular expression: ^ *?+ *$
If the...
| |
by: Xiaoning He |
last post by:
hi currently i'm using a crawler called larbin to get some pages, it
hashes each url to an integer. This is not a good method comparing to
md5, however it's enough for me. Currently i set the hash value to be
a 31-bit integer, which is used to be the index of a bit string in
memory, thus needs 256MB memory. i have 4GB+ free memory, so my
question is can i call for 4GB memory in my program in c++? or sixteen
256MB arrays. What about 8GB??
|
by: Chris Thomasson |
last post by:
Here is the code:
http://pastebin.com/m4a405e67
One advantage to using a region allocator is that you can usually skip most
calls to free. Instead you can merge multiple free calls into a single reset
call. Here is simple example:
___________________________________________________________________
|
by: Chris M. Thomasson |
last post by:
Here is the initial crude implmentation which compiles under Comeau with no
warnings:
___________________________________________________________________
#include <cassert>
#include <cstdlib>
#include <new>
#include <list>
template<typename T, std::size_t BUFDEPTH = 1024>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |