Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi ALL
I am trying to draw a picture using IDISPLAY_BitBlt at specific location. It does not print the image at the location I specify. It print it in it's old position. any reason. The code used for the above option is

Code :
IDISPLAY_BitBlt(p->a.m_pIDisplay,5,5,72,14,convData ,0,0,AEE_RO_COPY);
IDISPLAY_Update(p->a.m_pIDisplay);

Regards
Pramod

What is the code for drawing it in the "old" position? Also, as a general programming guideline, it is best to stay away from using "magic numbers" such as 5, 72 and 14! :)
Also, if you want to post code, you should use code tags to make it look more clear; quote this post to find out how, if you don't know already :). It doesn't matter much in this case, but long blocks of code with lots of indentation look much, much clearer with code tags! :)
IDISPLAY_BitBlt(p->a.m_pIDisplay,5,5,72,14,convData ,0,0,AEE_RO_COPY);
IDISPLAY_Update(p->a.m_pIDisplay);

What is the code for drawing it in the "old" position? Also, as a general programming guideline, it is best to stay away from using "magic numbers" such as 5, 72 and 14! :)
Also, if you want to post code, you should use code tags to make it look more clear; quote this post to find out how, if you don't know already :). It doesn't matter much in this case, but long blocks of code with lots of indentation look much, much clearer with code tags! :)
IDISPLAY_BitBlt(p->a.m_pIDisplay,5,5,72,14,convData ,0,0,AEE_RO_COPY);
IDISPLAY_Update(p->a.m_pIDisplay);

Thanx Simon
I will follow your suggestion. Actually it is not drawing the picture at all if I used to copy the image buffer and try to draw it
I am reading the bmp to buffer
copying it and drawing it in diffrent location
code:
____________________________________________________
p->m_imgBuffer=(char*)MALLOC(sizeof(p->m_BodyBuffer));
STRCPY(p->m_imgBuffer,p->m_BodyBuffer); //Copy the image buffer
convData=CONVERTBMP(p->m_BodyBuffer ,&(img),&(realloc));
convData=CONVERTBMP(p->m_imgBuffer ,&(img),&(realloc)); //Converting the Image buffer to bmp successfully
IDISPLAY_BitBlt(p->a.m_pIDisplay,5,5,72,14,convData ,0,0,AEE_RO_TRANSPARENT);
// Failed to draw bmp on screen
IDISPLAY_BitBlt(p->a.m_pIDisplay,xDest,yDest,xWidth,yHeight,convData ,0,0,AEE_RO_TRANSPARENT);
//Successfully drawn the bmp
IDISPLAY_Update(p->a.m_pIDisplay);
Is there any bugs in thecode? let me know
regards
pramod

Thanx Simon
I will follow your suggestion. Actually it is not drawing the picture at all if I used to copy the image buffer and try to draw it
I am reading the bmp to buffer
copying it and drawing it in diffrent location
code:
____________________________________________________
p->m_imgBuffer=(char*)MALLOC(sizeof(p->m_BodyBuffer));
STRCPY(p->m_imgBuffer,p->m_BodyBuffer); //Copy the image buffer
convData=CONVERTBMP(p->m_BodyBuffer ,&(img),&(realloc));
convData=CONVERTBMP(p->m_imgBuffer ,&(img),&(realloc)); //Converting the Image buffer to bmp successfully
IDISPLAY_BitBlt(p->a.m_pIDisplay,5,5,72,14,convData ,0,0,AEE_RO_TRANSPARENT);
// Failed to draw bmp on screen
IDISPLAY_BitBlt(p->a.m_pIDisplay,xDest,yDest,xWidth,yHeight,convData ,0,0,AEE_RO_TRANSPARENT);
//Successfully drawn the bmp
IDISPLAY_Update(p->a.m_pIDisplay);
Is there any bugs in thecode? let me know
regards
pramod

Quote:Originally posted by samalPramod
Is there any bugs in thecode? let me know
regards
pramod
Wow - plenty!
Firstly, m_BodyBuffer is not a string, so STRCPY will not work. Secondly, sizeof(p->m_BodyBuffer) will always return the same value - the size of a void pointer. Thirdly, with the lines
convData=CONVERTBMP(p->m_BodyBuffer ,&(img),&(realloc));
convData=CONVERTBMP(p->m_imgBuffer ,&(img),&(realloc));
the first line is pointless, as the initial value of convData will be overwritten by the second value without ever being used.
Fourthly, in the code given you are not freeing the m_imgBuffer after MALLOCing it, but I'm betting you do it somewhere else :)
Fifthly, your comments //Successfully drawn the bmp & // Failed to draw bitmap do not make sense, as they are not surrounded by any checks on whether the bitmaps have been drawn correctly.
In short, this block of code needs to be completely re-written from scratch. Post a description of what you are trying to do, and I'll try and sort it out for you :)
All the best,
Simon
Edit:
Without wanting to sound harsh, I highly recommend Dragon's earlier suggestion of reading some good books on C (and C++, if you will be using it) before you even attempt to write a BREW game.

Quote:Originally posted by samalPramod
Is there any bugs in thecode? let me know
regards
pramod
Wow - plenty!
Firstly, m_BodyBuffer is not a string, so STRCPY will not work. Secondly, sizeof(p->m_BodyBuffer) will always return the same value - the size of a void pointer. Thirdly, with the lines
convData=CONVERTBMP(p->m_BodyBuffer ,&(img),&(realloc));
convData=CONVERTBMP(p->m_imgBuffer ,&(img),&(realloc));
the first line is pointless, as the initial value of convData will be overwritten by the second value without ever being used.
Fourthly, in the code given you are not freeing the m_imgBuffer after MALLOCing it, but I'm betting you do it somewhere else :)
Fifthly, your comments //Successfully drawn the bmp & // Failed to draw bitmap do not make sense, as they are not surrounded by any checks on whether the bitmaps have been drawn correctly.
In short, this block of code needs to be completely re-written from scratch. Post a description of what you are trying to do, and I'll try and sort it out for you :)
All the best,
Simon
Edit:
Without wanting to sound harsh, I highly recommend Dragon's earlier suggestion of reading some good books on C (and C++, if you will be using it) before you even attempt to write a BREW game.

Hi,
I just want to show where I am getting error. I can't put all these bulky code on the forum. m_Bodybuffer is string type and strcpy works fine budy that's why I have commented. so far convdata is concerned I can have diffrent variables. But that is not the case.
anyway thank for suggestion
Regards
Pramod

Hi,
I just want to show where I am getting error. I can't put all these bulky code on the forum. m_Bodybuffer is string type and strcpy works fine budy that's why I have commented. so far convdata is concerned I can have diffrent variables. But that is not the case.
anyway thank for suggestion
Regards
Pramod

Quote:Originally posted by samalPramod
m_Bodybuffer is string type and strcpy works fine budy that's why I have commented.
Let me clarify this: the p->m_BodyBuffer you are using in this line
convData=CONVERTBMP(p->m_BodyBuffer ,&(img),&(realloc));
is a string? Why are you using CONVERTBMP with a string? CONVERTBMP is supposed to take a pointer to a windows bitmap pointer. Also, do neither of the lines
convData=CONVERTBMP(p->m_BodyBuffer ,&(img),&(realloc));
and
STRCPY(p->m_imgBuffer,p->m_BodyBuffer); //Copy the image buffer
give you a warning or an error? I know you haven't posted the full code, but is this block you've given
p->m_imgBuffer=(char*)MALLOC(sizeof(p->m_BodyBuffer));
STRCPY(p->m_imgBuffer,p->m_BodyBuffer); //Copy the image buffer
convData=CONVERTBMP(p->m_BodyBuffer ,&(img),&(realloc));
convData=CONVERTBMP(p->m_imgBuffer ,&(img),&(realloc)); //Converting the Image buffer to bmp successfully
IDISPLAY_BitBlt(p->a.m_pIDisplay,5,5,72,14,convData ,0,0,AEE_RO_TRANSPARENT);
// Failed to draw bmp on screen
IDISPLAY_BitBlt(p->a.m_pIDisplay,xDest,yDest,xWidth,yHeight,convData ,0,0,AEE_RO_TRANSPARENT);
//Successfully drawn the bmp
IDISPLAY_Update(p->a.m_pIDisplay);
"complete" in that there is nothing missing "in the middle" of it? Also, can I see your declaration of p->m_BodyBuffer? What is it representing - the fact that you use it with CONVERTBMP suggests that it should be bitmap data, but the fact that you also treat it as a string suggests that it is a string, which is why I am so confused ;)
Best Wishes,
Simon
P.S.
Don't worry about posting lots of code; as long as it's not too bulky ;)

Quote:Originally posted by samalPramod
m_Bodybuffer is string type and strcpy works fine budy that's why I have commented.
Let me clarify this: the p->m_BodyBuffer you are using in this line
convData=CONVERTBMP(p->m_BodyBuffer ,&(img),&(realloc));
is a string? Why are you using CONVERTBMP with a string? CONVERTBMP is supposed to take a pointer to a windows bitmap pointer. Also, do neither of the lines
convData=CONVERTBMP(p->m_BodyBuffer ,&(img),&(realloc));
and
STRCPY(p->m_imgBuffer,p->m_BodyBuffer); //Copy the image buffer
give you a warning or an error? I know you haven't posted the full code, but is this block you've given
p->m_imgBuffer=(char*)MALLOC(sizeof(p->m_BodyBuffer));
STRCPY(p->m_imgBuffer,p->m_BodyBuffer); //Copy the image buffer
convData=CONVERTBMP(p->m_BodyBuffer ,&(img),&(realloc));
convData=CONVERTBMP(p->m_imgBuffer ,&(img),&(realloc)); //Converting the Image buffer to bmp successfully
IDISPLAY_BitBlt(p->a.m_pIDisplay,5,5,72,14,convData ,0,0,AEE_RO_TRANSPARENT);
// Failed to draw bmp on screen
IDISPLAY_BitBlt(p->a.m_pIDisplay,xDest,yDest,xWidth,yHeight,convData ,0,0,AEE_RO_TRANSPARENT);
//Successfully drawn the bmp
IDISPLAY_Update(p->a.m_pIDisplay);
"complete" in that there is nothing missing "in the middle" of it? Also, can I see your declaration of p->m_BodyBuffer? What is it representing - the fact that you use it with CONVERTBMP suggests that it should be bitmap data, but the fact that you also treat it as a string suggests that it is a string, which is why I am so confused ;)
Best Wishes,
Simon
P.S.
Don't worry about posting lots of code; as long as it's not too bulky ;)

Ok. CONVERTBMP takes void type pointer rather than char* and convert it to native format. But I have taken char* for some change. anyway you can typecast that to void type. Forget about char* . Suppose I take void type pointer to source buffer and then use CONVERTBMP it will draw at first time. But if I do MEMCPY of the sourcebuffer then user convertbmp to convert it to natice format it dont do. Actually there is no error in either of the case whether you use a void pointer or char pointer. It executes the code CONVERTBMP with out any error or warning. But It is not able to draw the native bmp on emulator. Actually what I am doing is reading the image file and storing it in the buffer and then use convertbmp to convert it into window native format. But if I copy the buffer then try convertbmp on the copied buffer, though it is able to convert it to window native format but could not able to draw it using IDISPLAY_BitBlt.It even does not give any error or warning to me. One more thing I would like to mention that if I am using the copied buffer in the same procedure then it will able to display the bmp. but if i pass the buffer to other procedure it will not able draw the bmp. but execute all the code of the proc with out any warning or erro. I am attaching the text of the proc for you
Regards
Pramod

Ok. CONVERTBMP takes void type pointer rather than char* and convert it to native format. But I have taken char* for some change. anyway you can typecast that to void type. Forget about char* . Suppose I take void type pointer to source buffer and then use CONVERTBMP it will draw at first time. But if I do MEMCPY of the sourcebuffer then user convertbmp to convert it to natice format it dont do. Actually there is no error in either of the case whether you use a void pointer or char pointer. It executes the code CONVERTBMP with out any error or warning. But It is not able to draw the native bmp on emulator. Actually what I am doing is reading the image file and storing it in the buffer and then use convertbmp to convert it into window native format. But if I copy the buffer then try convertbmp on the copied buffer, though it is able to convert it to window native format but could not able to draw it using IDISPLAY_BitBlt.It even does not give any error or warning to me. One more thing I would like to mention that if I am using the copied buffer in the same procedure then it will able to display the bmp. but if i pass the buffer to other procedure it will not able draw the bmp. but execute all the code of the proc with out any warning or erro. I am attaching the text of the proc for you
Regards
Pramod

Thanks for attaching the code; it helps me out a lot :)
You are correct that CONVERTBMP does not complain about being handed a char*; presumably it doesn't complain because it is a macro, and has no strict type-checking.
The problem, as I guessed originally, is that neither p->m_BodyBuffer not p->m_imgBuffer are in fact strings; just taking a pointer and casting it to a char* does not make it a string. They are both (or should be, if you are using CONVERTBMP on them) pointers to bitmap data, and while passing them to STRCPY may not trigger any warnings or errors, it will definitely not behave the way you intended: STRCPY will copy an are of memory only until it hits a byte which is set to zero; since there are probably several zeros in a windows bitmap before we even reach the end of a colour table, it will not copy all of p->m_BodyBuffer into p->m_imgBuffer. In other words, p->m_imgBuffer will almost certainly not point to a copy of p->m_BodyBuffer after using your STRCPY line; at best, it will contain only that initial part of p->m_BodyBuffer that contains no zeros. I hope this makes some sense :)
Also, you are MALLOC'ing the wrong size; sizeof(p->m_BodyBuffer) will always return the same size, the size of a char pointer (about 4, usually; try DBGPRINTF("\nsizeof(p->m_BodyBuffer)=%d", sizeof(p->m_BodyBuffer));.
I see what you are trying to do, and it simply will not work this way.
What will work is, if we know the size of the windows bitmap pointed to by p->m_BodyBuffer (let's call it bodyBufSize):
p->m_imgBuffer = MALLOC(bodyBufSize);
MEMCPY(p->m_imgBuffer, p->m_BodyBuffer, bodyBufSize);
As I said though, you must know the precise size of the windows bitmap pointed to by p->m_BodyBuffer.
Can I ask why you wish to make two copies of the same image? Why not just use BitBlt to blit convData to two different places and dispense with convData2 altogether? I see no reason why what you are trying to achieve could not be achieved without convData2...
I hope this post helps you out :)
Best Wishes,
Simon
Edit:
What I've written here may be wrong; the fact that it displays both images in the first function is very strange. Ignore the above for now; I'll have to think about it some more :)
Edit2:
Also, in the file you attached, you are not setting values for xDest,yDest,xWidth,yHeight,i, but if you are doing this in the full version of your code, this won't cause any problems :)
Edit3:
Just tried your code and, as expected, convData2 was NULL in DisplayImage. Are you sure that DisplayImage displayed your image twice? It really shouldn't have done...
Edit4:
convData2 was also NULL in DisplayImageTwo, and I got the "Convertbmp Failed" DBGPRINTF message.

Thanks for attaching the code; it helps me out a lot :)
You are correct that CONVERTBMP does not complain about being handed a char*; presumably it doesn't complain because it is a macro, and has no strict type-checking.
The problem, as I guessed originally, is that neither p->m_BodyBuffer not p->m_imgBuffer are in fact strings; just taking a pointer and casting it to a char* does not make it a string. They are both (or should be, if you are using CONVERTBMP on them) pointers to bitmap data, and while passing them to STRCPY may not trigger any warnings or errors, it will definitely not behave the way you intended: STRCPY will copy an are of memory only until it hits a byte which is set to zero; since there are probably several zeros in a windows bitmap before we even reach the end of a colour table, it will not copy all of p->m_BodyBuffer into p->m_imgBuffer. In other words, p->m_imgBuffer will almost certainly not point to a copy of p->m_BodyBuffer after using your STRCPY line; at best, it will contain only that initial part of p->m_BodyBuffer that contains no zeros. I hope this makes some sense :)
Also, you are MALLOC'ing the wrong size; sizeof(p->m_BodyBuffer) will always return the same size, the size of a char pointer (about 4, usually; try DBGPRINTF("\nsizeof(p->m_BodyBuffer)=%d", sizeof(p->m_BodyBuffer));.
I see what you are trying to do, and it simply will not work this way.
What will work is, if we know the size of the windows bitmap pointed to by p->m_BodyBuffer (let's call it bodyBufSize):
p->m_imgBuffer = MALLOC(bodyBufSize);
MEMCPY(p->m_imgBuffer, p->m_BodyBuffer, bodyBufSize);
As I said though, you must know the precise size of the windows bitmap pointed to by p->m_BodyBuffer.
Can I ask why you wish to make two copies of the same image? Why not just use BitBlt to blit convData to two different places and dispense with convData2 altogether? I see no reason why what you are trying to achieve could not be achieved without convData2...
I hope this post helps you out :)
Best Wishes,
Simon
Edit:
What I've written here may be wrong; the fact that it displays both images in the first function is very strange. Ignore the above for now; I'll have to think about it some more :)
Edit2:
Also, in the file you attached, you are not setting values for xDest,yDest,xWidth,yHeight,i, but if you are doing this in the full version of your code, this won't cause any problems :)
Edit3:
Just tried your code and, as expected, convData2 was NULL in DisplayImage. Are you sure that DisplayImage displayed your image twice? It really shouldn't have done...
Edit4:
convData2 was also NULL in DisplayImageTwo, and I got the "Convertbmp Failed" DBGPRINTF message.

Thanx Simon
Actually I was wrong allocating the memory. once I provide with the exact amount of buffer it worked fine. Thanks for the help
Regards
Pramod

Thanx Simon
Actually I was wrong allocating the memory. once I provide with the exact amount of buffer it worked fine. Thanks for the help
Regards
Pramod

Quote:Originally posted by samalPramod
Thanx Simon
Actually I was wrong allocating the memory. once I provide with the exact amount of buffer it worked fine. Thanks for the help
Regards
Pramod
Hi, Samal,
I want to display a bitmap on screen on a designated place. I guess IDISPLAY_BitBlt() is the only way to do it, right?
From seeing your code, how do you read in the source bitmap? Do you read the bitmap file into buffer (AEEImageInfo) first, then use IDISPLAY_BitBlt() to display it on screen?
Since you have it working, could you show me a working sample using IDISPLAY_BitBlt()? Thank you.

Quote:Originally posted by samalPramod
Thanx Simon
Actually I was wrong allocating the memory. once I provide with the exact amount of buffer it worked fine. Thanks for the help
Regards
Pramod
Hi, Samal,
I want to display a bitmap on screen on a designated place. I guess IDISPLAY_BitBlt() is the only way to do it, right?
From seeing your code, how do you read in the source bitmap? Do you read the bitmap file into buffer (AEEImageInfo) first, then use IDISPLAY_BitBlt() to display it on screen?
Since you have it working, could you show me a working sample using IDISPLAY_BitBlt()? Thank you.

check out the faqs:
How do I load images from a file or from a resource file?
https://brewx.qualcomm.com/bws/content/gi/common/appseng/en/developerfaq...
How do I create an IIMAGE object from an in-memory bitmap?
https://brewx.qualcomm.com/bws/content/gi/common/appseng/en/developerfaq...
-Tyndal

check out the faqs:
How do I load images from a file or from a resource file?
https://brewx.qualcomm.com/bws/content/gi/common/appseng/en/developerfaq...
How do I create an IIMAGE object from an in-memory bitmap?
https://brewx.qualcomm.com/bws/content/gi/common/appseng/en/developerfaq...
-Tyndal